WaitForJob() public static method

public static WaitForJob ( string jobId, JobState jobState, Action verifyAction, Action progressChangedAction = null ) : void
jobId string
jobState JobState
verifyAction Action
progressChangedAction Action
return void
        private IAsset RunJobAndGetOutPutAsset(string jobName, out IAsset asset, out IJob job)
        {
            asset = CreateAsset(_mediaContext, _smallWmv, AssetCreationOptions.StorageEncrypted);
            IMediaProcessor mediaProcessor = JobTests.GetMediaProcessor(_mediaContext, WindowsAzureMediaServicesTestConfiguration.MpEncoderName);

            job = JobTests.CreateAndSubmitOneTaskJob(_mediaContext, jobName, mediaProcessor, JobTests.GetWamePreset(mediaProcessor), asset, TaskOptions.None);
            JobTests.WaitForJob(job.Id, JobState.Finished, JobTests.VerifyAllTasksFinished);
            Assert.IsTrue(job.OutputMediaAssets.Count > 0);
            IAsset outasset = job.OutputMediaAssets[0];

            Assert.IsNotNull(outasset);
            return(outasset);
        }
        public void ShouldGetClearConfigurationFromTask()
        {
            var    filePaths = new[] { WindowsAzureMediaServicesTestConfiguration.SmallIsm, WindowsAzureMediaServicesTestConfiguration.SmallIsmc, WindowsAzureMediaServicesTestConfiguration.SmallIsmv };
            IAsset asset     = _mediaContext.Assets.Create(Guid.NewGuid().ToString(), AssetCreationOptions.StorageEncrypted);

            foreach (string filePath in filePaths)
            {
                string     filename = Path.GetFileName(filePath);
                IAssetFile file     = asset.AssetFiles.Create(filename);
                file.Upload(filePath);
                if (WindowsAzureMediaServicesTestConfiguration.SmallIsm == filePath)
                {
                    file.IsPrimary = true;
                    file.Update();
                }
            }

            string          originalConfiguration = File.ReadAllText(WindowsAzureMediaServicesTestConfiguration.PlayReadyConfig);
            IMediaProcessor processor             = JobTests.GetMediaProcessor(_mediaContext, WindowsAzureMediaServicesTestConfiguration.MpEncryptorName);

            IJob  job  = _mediaContext.Jobs.Create("PlayReady protect a smooth streaming asset for GetClearConfigurationFromTask");
            ITask task = job.Tasks.AddNew("SmoothProtectTask", processor, originalConfiguration, TaskOptions.ProtectedConfiguration);

            task.InputAssets.Add(asset);
            task.OutputAssets.AddNew("Job OutPut", AssetCreationOptions.None);

            // Verify that we can get the configuration back before we create a job template.  Note that is the point that things actually get encrypted
            Assert.AreEqual(String.CompareOrdinal(task.GetClearConfiguration(), originalConfiguration), 0);
            job.Submit();
            Assert.AreEqual(job.Tasks.Count, 1);
            Assert.AreEqual(TaskOptions.ProtectedConfiguration, job.Tasks[0].Options);
            Assert.IsNotNull(job.Tasks[0].InitializationVector);
            Assert.IsFalse(String.IsNullOrEmpty(job.Tasks[0].EncryptionKeyId));
            Assert.AreEqual(ConfigurationEncryption.SchemeName, job.Tasks[0].EncryptionScheme);
            Assert.AreEqual(ConfigurationEncryption.SchemeVersion, job.Tasks[0].EncryptionVersion);

            JobTests.WaitForJob(job.Id, JobState.Finished, JobTests.VerifyAllTasksFinished);

            // Verify that the configuration isn't clear
            Assert.AreNotEqual(String.CompareOrdinal(job.Tasks[0].Configuration, originalConfiguration), 0);

            // Verify that we can decrypt the configuration and get the correct clear value
            string decryptedConfiguration = job.Tasks[0].GetClearConfiguration();

            Assert.AreEqual(String.CompareOrdinal(decryptedConfiguration, originalConfiguration), 0);
        }
        public void ShouldCreateTaskUsingStorageEncryptedAsset()
        {
            var             filePaths = new[] { WindowsAzureMediaServicesTestConfiguration.SmallWmv };
            IAsset          asset     = AssetTests.CreateAsset(_mediaContext, Path.GetFullPath(WindowsAzureMediaServicesTestConfiguration.SmallWmv), AssetCreationOptions.StorageEncrypted);
            IMediaProcessor processor = JobTests.GetEncoderMediaProcessor(_mediaContext);
            IJob            job       = _mediaContext.Jobs.Create("Encode Job with encrypted asset");
            ITask           task      = job.Tasks.AddNew("Task 1", processor, JobTests.GetWamePreset(processor), TaskOptions.None);

            task.InputAssets.Add(asset);
            task.OutputAssets.AddNew("Encrypted Output", AssetCreationOptions.StorageEncrypted);
            job.Submit();
            JobTests.WaitForJob(job.Id, JobState.Finished, JobTests.VerifyAllTasksFinished);

            CloudMediaContext context2 = WindowsAzureMediaServicesTestConfiguration.CreateCloudMediaContext();
            IJob job2 = context2.Jobs.Where(c => c.Id == job.Id).Single();

            foreach (IAsset outputAsset in job2.Tasks[0].OutputAssets)
            {
                VerifyFileAndContentKeyMetadataForStorageEncryption(outputAsset, _mediaContext);
            }
        }
Esempio n. 4
0
        public void ApplyDynamicManifestFilter()
        {
            const string typeAudio = "Type=\"audio\"";
            const string typeVideo = "Type=\"video\"";

            string          configuration  = File.ReadAllText(WindowsAzureMediaServicesTestConfiguration.DefaultMp4ToSmoothConfig);
            IAsset          inputAsset     = AssetTests.CreateAsset(_mediaContext, WindowsAzureMediaServicesTestConfiguration.SmallMp41, AssetCreationOptions.None);
            IMediaProcessor mediaProcessor = JobTests.GetMediaProcessor(_mediaContext, WindowsAzureMediaServicesTestConfiguration.MpPackagerName);
            IJob            job            = JobTests.CreateAndSubmitOneTaskJob(_mediaContext, "ApplyDynamicManifestFilter" + Guid.NewGuid().ToString().Substring(0, 5), mediaProcessor, configuration, inputAsset, TaskOptions.None);

            JobTests.WaitForJob(job.Id, JobState.Finished, JobTests.VerifyAllTasksFinished);


            var outputAsset = job.OutputMediaAssets.FirstOrDefault();

            outputAsset = _mediaContext.Assets.Where(c => c.Id == outputAsset.Id).FirstOrDefault();
            var assetFile = outputAsset.AssetFiles.Where(c => c.Name.EndsWith(".ism")).First();

            IAccessPolicy policy        = _mediaContext.AccessPolicies.Create("ApplyDynamicManifestFilter" + Guid.NewGuid().ToString().Substring(0, 5), TimeSpan.FromDays(30), AccessPermissions.Read);
            ILocator      originLocator = _mediaContext.Locators.CreateLocator(LocatorType.OnDemandOrigin, outputAsset, policy, DateTime.UtcNow.AddMinutes(-5));

            string     urlForClientStreaming = originLocator.Path + assetFile.Name + "/manifest";
            HttpClient client  = new HttpClient();
            var        message = client.GetAsync(urlForClientStreaming).Result;
            var        content = message.Content;
            var        result  = content.ReadAsStringAsync().Result;

            Assert.AreEqual(message.StatusCode, HttpStatusCode.OK);
            Assert.IsTrue(result.Length > 0);

            Assert.IsTrue(result.Contains(typeAudio));

            Assert.IsTrue(result.Contains(typeVideo));

            var manifestLength = result.Length;

            // string filterName = "ApplyDynamicManifestFilter_" + DateTime.Now;
            string filterName = "ApplyDynamicManifestFilter_" + Guid.NewGuid().ToString().Substring(0, 5);
            List <FilterTrackSelectStatement> filterTrackSelectStatements = new List <FilterTrackSelectStatement>();
            FilterTrackSelectStatement        filterTrackSelectStatement  = new FilterTrackSelectStatement();

            filterTrackSelectStatement.PropertyConditions = new List <IFilterTrackPropertyCondition>();
            filterTrackSelectStatement.PropertyConditions.Add(new FilterTrackTypeCondition(FilterTrackType.Video, FilterTrackCompareOperator.NotEqual));
            filterTrackSelectStatements.Add(filterTrackSelectStatement);
            IStreamingFilter filter = _mediaContext.Filters.Create(filterName, new PresentationTimeRange(), filterTrackSelectStatements);

            Assert.IsNotNull(filter);


            var        filterUrlForClientStreaming = originLocator.Path + assetFile.Name + String.Format("/manifest(filter={0})", filterName);
            HttpClient filterclient  = new HttpClient();
            var        filtermessage = filterclient.GetAsync(filterUrlForClientStreaming).Result;

            Assert.AreEqual(filtermessage.StatusCode, HttpStatusCode.OK);
            var filtercontent = filtermessage.Content;
            var filterresult  = filtercontent.ReadAsStringAsync().Result;

            Assert.IsTrue(filterresult.Length > 0);
            Assert.AreNotEqual(manifestLength, filterresult);
            Assert.IsTrue(filterresult.Contains(typeAudio));
            Assert.IsFalse(filterresult.Contains(typeVideo));

            outputAsset.DeleteAsync();
            inputAsset.DeleteAsync();
            job.DeleteAsync();
            filter.DeleteAsync();
        }