public static GetMediaProcessor ( CloudMediaContext context, string mpName ) : IMediaProcessor | ||
context | CloudMediaContext | |
mpName | string | |
return | IMediaProcessor |
private IAsset CreateHlsFromSmoothAsset(IAsset sourceAsset, AssetCreationOptions options) { IJob job = _mediaContext.Jobs.Create("Smooth to Hls Job"); IMediaProcessor mediaProcessor = JobTests.GetMediaProcessor(_mediaContext, WindowsAzureMediaServicesTestConfiguration.MpEncryptorName); string smoothToHlsConfiguration = null; if (options == AssetCreationOptions.EnvelopeEncryptionProtected) { smoothToHlsConfiguration = File.ReadAllText(WindowsAzureMediaServicesTestConfiguration.SmoothToEncryptHlsConfig); } else { smoothToHlsConfiguration = File.ReadAllText(WindowsAzureMediaServicesTestConfiguration.SmoothToHlsConfig); } ITask task = job.Tasks.AddNew("Smooth to Hls conversion task", mediaProcessor, smoothToHlsConfiguration, TaskOptions.None); task.InputAssets.Add(sourceAsset); task.OutputAssets.AddNew("JobOutput", options); job.Submit(); job.GetExecutionProgressTask(CancellationToken.None).Wait(); job.Refresh(); return(job.OutputMediaAssets[0]); }
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); }
private IAsset CreatePlayReadyProtectedSmoothAsset(IAsset clearSmoothAssetToProtect) { Guid keyId = Guid.NewGuid(); byte[] keyValue = ContentKeyTests.GetRandomBuffer(16); string encryptionConfiguration = File.ReadAllText(WindowsAzureMediaServicesTestConfiguration.PlayReadyConfigWithContentKey); encryptionConfiguration = JobTests.UpdatePlayReadyConfigurationXML(keyId, keyValue, new Uri("http://www.fakeurl.com"), encryptionConfiguration); IJob job = _mediaContext.Jobs.Create("Add PlayReady Protection Job"); IMediaProcessor mediaProcessor = JobTests.GetMediaProcessor(_mediaContext, WindowsAzureMediaServicesTestConfiguration.MpEncryptorName); ITask task = job.Tasks.AddNew("PlayReady Encryption Task", mediaProcessor, encryptionConfiguration, TaskOptions.ProtectedConfiguration); task.InputAssets.Add(clearSmoothAssetToProtect); task.OutputAssets.AddNew("PlayReady Protected Smooth", AssetCreationOptions.CommonEncryptionProtected); job.Submit(); job.GetExecutionProgressTask(CancellationToken.None).Wait(); job.Refresh(); return(job.OutputMediaAssets[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(); }