Exemplo n.º 1
0
        public AssetFilter GetAssetFilter(string filterId)
        {
            AssetFilter    returnFilter = new AssetFilter();
            HttpWebRequest request      = (HttpWebRequest)WebRequest.Create(string.Format(CultureInfo.InvariantCulture, "{0}AssetFilters('{1}')", WamsEndpoint, HttpUtility.UrlEncode(filterId)));

            request.Method      = HttpVerbs.Get;
            request.ContentType = RequestContentType.Json;
            request.Accept      = RequestContentType.Json;
            request.Headers.Add(RequestHeaders.XMsVersion, RequestHeaderValues.XMsVersion);
            request.Headers.Add(RequestHeaders.Authorization, string.Format(CultureInfo.InvariantCulture, RequestHeaderValues.Authorization, AccessToken));
            request.Headers.Add(RequestHeaders.DataServiceVersion, RequestHeaderValues.DataServiceVersion);
            request.Headers.Add(RequestHeaders.MaxDataServiceVersion, RequestHeaderValues.MaxDataServiceVersion);
            request.Headers.Add(RequestHeaders.XMsClientRequestId, "00000000");

            try
            {
                using (var response = (HttpWebResponse)request.GetResponse())
                {
                    using (StreamReader streamReader = new StreamReader(response.GetResponseStream(), true))
                    {
                        var returnBody = streamReader.ReadToEnd();

                        JObject responseJsonObject = JObject.Parse(returnBody);
                        // var value = responseJsonObject["Element"];

                        var serializer = new JavaScriptSerializer();
                        AssetFilterWithMetadata returnFilterm = (AssetFilterWithMetadata)serializer.Deserialize(responseJsonObject.ToString(), typeof(AssetFilterWithMetadata));

                        returnFilter.Name = returnFilterm.Name;
                        returnFilter.PresentationTimeRange = returnFilterm.PresentationTimeRange;
                        returnFilter.Tracks        = returnFilterm.Tracks;
                        returnFilter.Id            = returnFilterm.Id;
                        returnFilter.ParentAssetId = returnFilterm.ParentAssetId;
                        returnFilter.SetContext(this);
                    }
                }
            }
            catch (Exception e)
            {
                returnFilter = null;
            }
            return(returnFilter);
        }
        private void DoSubClip()
        {
            var subclipConfig = this.GetSubclippingConfiguration();

            if (subclipConfig.Reencode) // reencode the clip
            {
                List<IMediaProcessor> Procs = Mainform.GetMediaProcessorsByName(Constants.AzureMediaEncoderStandard);
                EncodingAMEStandard form2 = new EncodingAMEStandard(_context, subclipConfig)
                {
                    EncodingLabel = (_selectedAssets.Count > 1) ? _selectedAssets.Count + " assets have been selected. " + _selectedAssets.Count + " jobs will be submitted." : "Asset '" + _selectedAssets.FirstOrDefault().Name + "' will be encoded.",
                    EncodingProcessorsList = Procs,
                    EncodingJobName = "Subclipping with reencoding of " + Constants.NameconvInputasset,
                    EncodingOutputAssetName = Constants.NameconvInputasset + "- Subclipped with reencoding",
                    EncodingAMEStdPresetJSONFilesUserFolder = Properties.Settings.Default.AMEStandardPresetXMLFilesCurrentFolder,
                    EncodingAMEStdPresetJSONFilesFolder = Application.StartupPath + Constants.PathAMEStdFiles,
                    SelectedAssets = _selectedAssets
                };

                if (form2.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    string taskname = "Subclipping with reencoding of " + Constants.NameconvInputasset + " with " + Constants.NameconvEncodername;
                    _mainform.LaunchJobs(
                       form2.EncodingProcessorSelected,
                       _selectedAssets,
                       form2.EncodingJobName,
                       form2.JobOptions.Priority,
                       taskname,
                       form2.EncodingOutputAssetName,
                       new List<string>() { form2.EncodingConfiguration },
                       form2.JobOptions.OutputAssetsCreationOptions,
                       form2.JobOptions.TasksOptionsSetting,
                       form2.JobOptions.StorageSelected);

                }
            }
            else if (subclipConfig.CreateAssetFilter) // create a asset filter
            {
                IAsset selasset = _selectedAssets.FirstOrDefault();
                DynManifestFilter formAF = new DynManifestFilter(_contextdynmanifest, _context, null, selasset, subclipConfig);
                if (formAF.ShowDialog() == DialogResult.OK)
                {
                    AssetFilter myassetfilter = new AssetFilter(selasset);

                    Filter filter = formAF.GetFilter;
                    myassetfilter.Name = filter.Name;
                    myassetfilter.PresentationTimeRange = filter.PresentationTimeRange;
                    myassetfilter.Tracks = filter.Tracks;
                    myassetfilter._context = filter._context;
                    try
                    {
                        myassetfilter.Create();
                        _mainform.TextBoxLogWriteLine("Asset filter '{0}' created.", myassetfilter.Name);
                    }
                    catch (Exception ex)
                    {
                        _mainform.TextBoxLogWriteLine("Error when creating filter '{0}'.", myassetfilter.Name, true);
                        _mainform.TextBoxLogWriteLine(ex);
                    }

                    _mainform.DoRefreshGridFiltersV(false);
                }

            }
            else // no reencode or asset filter but stream copy
            {
                string taskname = "Subclipping of " + Constants.NameconvInputasset + " with " + Constants.NameconvEncodername;
                IMediaProcessor Proc = Mainform.GetLatestMediaProcessorByName(Constants.AzureMediaEncoderStandard);

                _mainform.LaunchJobs(
                    Proc,
                    _selectedAssets,
                    this.EncodingJobName,
                    this.JobOptions.Priority,
                    taskname,
                    this.EncodingOutputAssetName,
                    new List<string>() { this.GetSubclippingConfiguration().Configuration },
                    this.JobOptions.OutputAssetsCreationOptions,
                    this.JobOptions.TasksOptionsSetting,
                    this.JobOptions.StorageSelected);

                MessageBox.Show("Subclipping job(s) submitted", "Sublipping", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Exemplo n.º 3
0
        private async Task DoSubClipAsync()
        {
            var subclipConfig = this.GetSubclippingInternalConfiguration();

            if (subclipConfig.Reencode) // reencode the clip
            {
                ProcessFromTransform form = new ProcessFromTransform(_amsClientV3, _mainform, _selectedAssets, null, subclipConfig.StartTime, subclipConfig.EndTime, true);

                if (form.ShowDialog() == DialogResult.OK)
                {
                    await _mainform.CreateAndSubmitJobsAsync(new List <Transform>() { form.SelectedTransform }, _selectedAssets, form.StartClipTime, form.EndClipTime);
                }

                /*
                 * var processor = Mainform.GetLatestMediaProcessorByName(Constants.AzureMediaEncoderStandard);
                 * EncodingMES form2 = new EncodingMES(_context, new List<IAsset>(), processor.Version, _mainform, subclipConfig, disableOverlay: true)
                 * {
                 *  EncodingLabel = (_selectedAssets.Count > 1) ?
                 *                  string.Format("{0} asset{1} selected. You are going to submit {0} job{1} with 1 task.", _selectedAssets.Count, Program.ReturnS(_selectedAssets.Count), _selectedAssets.Count)
                 *                  :
                 *                  "Asset '" + _selectedAssets.FirstOrDefault().Name + "' will be encoded (1 job with 1 task).",
                 *
                 *  EncodingJobName = "Subclipping with reencoding of " + Constants.NameconvInputasset,
                 *  EncodingOutputAssetName = Constants.NameconvInputasset + "- Subclipped with reencoding",
                 *  EncodingAMEStdPresetJSONFilesUserFolder = Properties.Settings.Default.MESPresetFilesCurrentFolder,
                 *  EncodingAMEStdPresetJSONFilesFolder = Application.StartupPath + Constants.PathMESFiles,
                 *  SelectedAssets = _selectedAssets
                 * };
                 *
                 * if (form2.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                 * {
                 *  string taskname = "Subclipping with reencoding of " + Constants.NameconvInputasset + " with " + Constants.NameconvEncodername;
                 *  _mainform.LaunchJobs_OneJobPerInputAsset_OneTaskPerfConfig(
                 *     processor,
                 *     _selectedAssets,
                 *     form2.EncodingJobName,
                 *     form2.JobOptions.Priority,
                 *     taskname,
                 *     form2.EncodingOutputAssetName,
                 *     new List<string>() { form2.EncodingConfiguration },
                 *     form2.JobOptions.OutputAssetsCreationOptions,
                 *     form2.JobOptions.OutputAssetsFormatOption,
                 *     form2.JobOptions.TasksOptionsSetting,
                 *     form2.JobOptions.StorageSelected);
                 * }
                 */
            }
            else if (subclipConfig.CreateAssetFilter) // create a asset filter
            {
                Asset             selasset = _selectedAssets.FirstOrDefault();
                DynManifestFilter formAF   = new DynManifestFilter(_amsClientV3, null, selasset, subclipConfig);
                if (formAF.ShowDialog() == DialogResult.OK)
                {
                    FilterCreationInfo filterinfo = null;
                    try
                    {
                        filterinfo = formAF.GetFilterInfo;
                        AssetFilter assetFilter = new AssetFilter()
                        {
                            PresentationTimeRange = filterinfo.Presentationtimerange
                        };

                        await _amsClientV3.AMSclient.AssetFilters.CreateOrUpdateAsync(_amsClientV3.credentialsEntry.ResourceGroup, _amsClientV3.credentialsEntry.AccountName, selasset.Name, filterinfo.Name, assetFilter);

                        _mainform.TextBoxLogWriteLine("Asset filter '{0}' created.", filterinfo.Name);
                    }
                    catch (Exception ex)
                    {
                        _mainform.TextBoxLogWriteLine("Error when creating filter '{0}'.", (filterinfo != null && filterinfo.Name != null) ? filterinfo.Name : "unknown name", true);
                        _mainform.TextBoxLogWriteLine(ex);
                    }

                    await _mainform.DoRefreshGridFiltersVAsync(false);
                }
            }
            else // no reencode or asset filter but stream copy
            {
                ClipTime startTime = null;
                ClipTime endTime   = null;

                if (checkBoxTrimming.Checked)
                {
                    startTime = new AbsoluteClipTime()
                    {
                        Time = subclipConfig.StartTime
                    };

                    endTime = new AbsoluteClipTime()
                    {
                        Time = subclipConfig.EndTime
                    };
                }

                var transform = await _mainform.CreateAndGetCopyCodecTransformIfNeededAsync();

                await _mainform.CreateAndSubmitJobsAsync(new List <Transform>() { transform }, _selectedAssets, startTime, endTime, EncodingJobName, EncodingOutputAssetName);

                MessageBox.Show("Subclipping job(s) submitted", "Sublipping", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            GenerateUniqueNamesForJobAndOutput();
        }
        public AssetFilter GetAssetFilter(string filterId)
        {
            AssetFilter returnFilter = new AssetFilter();
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(string.Format(CultureInfo.InvariantCulture, "{0}AssetFilters('{1}')", WamsEndpoint, HttpUtility.UrlEncode(filterId)));
            request.Method = HttpVerbs.Get;
            request.ContentType = RequestContentType.Json;
            request.Accept = RequestContentType.Json;
            request.Headers.Add(RequestHeaders.XMsVersion, RequestHeaderValues.XMsVersion);
            request.Headers.Add(RequestHeaders.Authorization, string.Format(CultureInfo.InvariantCulture, RequestHeaderValues.Authorization, AccessToken));
            request.Headers.Add(RequestHeaders.DataServiceVersion, RequestHeaderValues.DataServiceVersion);
            request.Headers.Add(RequestHeaders.MaxDataServiceVersion, RequestHeaderValues.MaxDataServiceVersion);
            request.Headers.Add(RequestHeaders.XMsClientRequestId, "00000000");

            try
            {
                using (var response = (HttpWebResponse)request.GetResponse())
                {
                    using (StreamReader streamReader = new StreamReader(response.GetResponseStream(), true))
                    {
                        var returnBody = streamReader.ReadToEnd();

                        JObject responseJsonObject = JObject.Parse(returnBody);
                        // var value = responseJsonObject["Element"];

                        var serializer = new JavaScriptSerializer();
                        AssetFilterWithMetadata returnFilterm = (AssetFilterWithMetadata)serializer.Deserialize(responseJsonObject.ToString(), typeof(AssetFilterWithMetadata));

                        returnFilter.Name = returnFilterm.Name;
                        returnFilter.PresentationTimeRange = returnFilterm.PresentationTimeRange;
                        returnFilter.Tracks = returnFilterm.Tracks;
                        returnFilter.Id = returnFilterm.Id;
                        returnFilter.ParentAssetId = returnFilterm.ParentAssetId;
                        returnFilter.SetContext(this);
                    }
                }
            }
            catch (Exception e)
            {
                returnFilter = null;
            }
            return returnFilter;
        }
        private void DoCreateAssetFilter()
        {
            IAsset selasset = ReturnSelectedAssetsFromProgramsOrAssets().FirstOrDefault();

            DynManifestFilter form = new DynManifestFilter(_contextdynmanifest, _context, null, selasset);

            if (form.ShowDialog() == DialogResult.OK)
            {
                AssetFilter myassetfilter = new AssetFilter(selasset);

                Filter filter = form.GetFilter;
                myassetfilter.Name = filter.Name;
                myassetfilter.PresentationTimeRange = filter.PresentationTimeRange;
                myassetfilter.Tracks = filter.Tracks;
                myassetfilter._context = filter._context;
                try
                {
                    myassetfilter.Create();
                    TextBoxLogWriteLine("Asset filter '{0}' created.", myassetfilter.Name);
                }
                catch (Exception e)
                {
                    TextBoxLogWriteLine("Error when creating filter '{0}'.", myassetfilter.Name, true);
                    TextBoxLogWriteLine(e);
                }
                DoRefreshGridFiltersV(false);
            }

        }
        private void DoDuplicateFilter()
        {
            var filters = ReturnSelectedFilters();
            if (filters.Count == 1)
            {
                AssetFilter sourcefilter = filters.FirstOrDefault();

                string newfiltername = sourcefilter.Name + "Copy";
                if (Program.InputBox("New name", "Enter the name of the new duplicate filter:", ref newfiltername) == DialogResult.OK)
                {
                    AssetFilter copyfilter = new AssetFilter(myAsset);
                    copyfilter.Name = newfiltername;
                    copyfilter.PresentationTimeRange = sourcefilter.PresentationTimeRange;
                    copyfilter.Tracks = sourcefilter.Tracks;
                    copyfilter._context = sourcefilter._context;
                    try
                    {
                        copyfilter.Create();
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show("Error when duplicating asset filter.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    DisplayAssetFilters();
                }
            }
        }
        private void DoCreateAssetFilter()
        {
            DynManifestFilter form = new DynManifestFilter(_contextdynmanifest, myContext, null, myAsset);
            form.CreateAssetFilterFromAssetName = myAsset.Name;

            if (form.ShowDialog() == DialogResult.OK)
            {
                AssetFilter myassetfilter = new AssetFilter(myAsset);

                Filter filter = form.GetFilter;
                myassetfilter.Name = filter.Name;
                myassetfilter.PresentationTimeRange = filter.PresentationTimeRange;
                myassetfilter.Tracks = filter.Tracks;
                myassetfilter._context = filter._context;
                try
                {
                    myassetfilter.Create();
                    myMainForm.TextBoxLogWriteLine("Asset filter '{0}' has been created.", filter.Name);
                }
                catch (Exception e)
                {
                    MessageBox.Show("Error when creating asset filter.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    myMainForm.TextBoxLogWriteLine("Error when creating asset filter '{0}'.", filter.Name, true);
                    myMainForm.TextBoxLogWriteLine(e);
                }
                DisplayAssetFilters();
            }
        }
Exemplo n.º 8
0
        private void DoSubClip()
        {
            var subclipConfig = this.GetSubclippingConfiguration();

            if (subclipConfig.Reencode) // reencode the clip
            {
                List <IMediaProcessor> Procs = Mainform.GetMediaProcessorsByName(Constants.AzureMediaEncoderStandard);
                EncodingAMEStandard    form2 = new EncodingAMEStandard(_context, subclipConfig)
                {
                    EncodingLabel           = (_selectedAssets.Count > 1) ? _selectedAssets.Count + " assets have been selected. " + _selectedAssets.Count + " jobs will be submitted." : "Asset '" + _selectedAssets.FirstOrDefault().Name + "' will be encoded.",
                    EncodingProcessorsList  = Procs,
                    EncodingJobName         = "Subclipping with reencoding of " + Constants.NameconvInputasset,
                    EncodingOutputAssetName = Constants.NameconvInputasset + "- Subclipped with reencoding",
                    EncodingAMEStdPresetJSONFilesUserFolder = Properties.Settings.Default.AMEStandardPresetXMLFilesCurrentFolder,
                    EncodingAMEStdPresetJSONFilesFolder     = Application.StartupPath + Constants.PathAMEStdFiles,
                    SelectedAssets = _selectedAssets
                };

                if (form2.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    string taskname = "Subclipping with reencoding of " + Constants.NameconvInputasset + " with " + Constants.NameconvEncodername;
                    _mainform.LaunchJobs(
                        form2.EncodingProcessorSelected,
                        _selectedAssets,
                        form2.EncodingJobName,
                        form2.JobOptions.Priority,
                        taskname,
                        form2.EncodingOutputAssetName,
                        new List <string>()
                    {
                        form2.EncodingConfiguration
                    },
                        form2.JobOptions.OutputAssetsCreationOptions,
                        form2.JobOptions.TasksOptionsSetting,
                        form2.JobOptions.StorageSelected);
                }
            }
            else if (subclipConfig.CreateAssetFilter) // create a asset filter
            {
                IAsset            selasset = _selectedAssets.FirstOrDefault();
                DynManifestFilter formAF   = new DynManifestFilter(_contextdynmanifest, _context, null, selasset, subclipConfig);
                if (formAF.ShowDialog() == DialogResult.OK)
                {
                    AssetFilter myassetfilter = new AssetFilter(selasset);

                    Filter filter = formAF.GetFilter;
                    myassetfilter.Name = filter.Name;
                    myassetfilter.PresentationTimeRange = filter.PresentationTimeRange;
                    myassetfilter.Tracks   = filter.Tracks;
                    myassetfilter._context = filter._context;
                    try
                    {
                        myassetfilter.Create();
                        _mainform.TextBoxLogWriteLine("Asset filter '{0}' created.", myassetfilter.Name);
                    }
                    catch (Exception ex)
                    {
                        _mainform.TextBoxLogWriteLine("Error when creating filter '{0}'.", myassetfilter.Name, true);
                        _mainform.TextBoxLogWriteLine(ex);
                    }

                    _mainform.DoRefreshGridFiltersV(false);
                }
            }
            else // no reencode or asset filter but stream copy
            {
                string          taskname = "Subclipping of " + Constants.NameconvInputasset + " with " + Constants.NameconvEncodername;
                IMediaProcessor Proc     = Mainform.GetLatestMediaProcessorByName(Constants.AzureMediaEncoderStandard);

                _mainform.LaunchJobs(
                    Proc,
                    _selectedAssets,
                    this.EncodingJobName,
                    this.JobOptions.Priority,
                    taskname,
                    this.EncodingOutputAssetName,
                    new List <string>()
                {
                    this.GetSubclippingConfiguration().Configuration
                },
                    this.JobOptions.OutputAssetsCreationOptions,
                    this.JobOptions.TasksOptionsSetting,
                    this.JobOptions.StorageSelected);

                MessageBox.Show("Subclipping job(s) submitted", "Sublipping", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }