/// <summary> /// Initializes a new instance of the <see cref="CloudMediaContext"/> class. /// </summary> /// <param name="apiServer">A <see cref="Uri"/> representing a the API endpoint.</param> /// <param name="accountName">The Microsoft WindowsAzure Media Services account name to authenticate with.</param> /// <param name="accountKey">The Microsoft WindowsAzure Media Services account key to authenticate with.</param> /// <param name="scope">The scope of authorization.</param> /// <param name="acsBaseAddress">The access control endpoint to authenticate against.</param> public CloudMediaContext(Uri apiServer, string accountName, string accountKey, string scope, string acsBaseAddress) { this.ParallelTransferThreadCount = 10; this.NumberOfConcurrentTransfers = 2; OAuthDataServiceAdapter dataServiceAdapter = new OAuthDataServiceAdapter(accountName, accountKey, scope, acsBaseAddress, NimbusRestApiCertificateThumbprint, NimbusRestApiCertificateSubject); ServiceVersionAdapter versionAdapter = new ServiceVersionAdapter(KnownApiVersions.Current); this._dataContextFactory = new AzureMediaServicesDataServiceContextFactory(apiServer, dataServiceAdapter, versionAdapter, this); this._jobs = new JobBaseCollection(this); this._jobTemplates = new JobTemplateBaseCollection(this); this._assets = new AssetCollection(this); this._files = new AssetFileCollection(this); this._accessPolicies = new AccessPolicyBaseCollection(this); this._contentKeys = new ContentKeyCollection(this); this._notificationEndPoints = new NotificationEndPointCollection(this); this._mediaProcessors = new MediaProcessorBaseCollection(this); this._locators = new LocatorBaseCollection(this); this._ingestManifests = new IngestManifestCollection(this); this._ingestManifestAssets = new IngestManifestAssetCollection(this, null); this._ingestManifestFiles = new IngestManifestFileCollection(this, null); this._storageAccounts = new StorageAccountBaseCollection(this); }
/// <summary> /// Returns a <see cref="IJob"/> instance with a single <see cref="ITask"/> ready to be submitted. /// </summary> /// <param name="jobs">The <see cref="JobBaseCollection"/> instance.</param> /// <param name="mediaProcessorName">The name of the media processor.</param> /// <param name="taskConfiguration">The task configuration.</param> /// <param name="inputAsset">The input <see cref="IAsset"/> instance.</param> /// <param name="strategy">The <see cref="IAccountSelectionStrategy"/> instance used to pick the output asset storage account.</param> /// <param name="outputAssetName">The name of the output asset.</param> /// <param name="outputAssetOptions">The <see cref="AssetCreationOptions"/> of the output asset.</param> /// <returns>A <see cref="IJob"/> instance with a single <see cref="ITask"/> ready to be submitted.</returns> public static IJob CreateWithSingleTask(this JobBaseCollection jobs, string mediaProcessorName, string taskConfiguration, IAsset inputAsset, IAccountSelectionStrategy strategy, string outputAssetName, AssetCreationOptions outputAssetOptions) { if (strategy == null) { throw new ArgumentNullException("strategy"); } string outputAssetStorageAccount = strategy.SelectAccountForAsset(); return(jobs.CreateWithSingleTask(mediaProcessorName, taskConfiguration, inputAsset, outputAssetName, outputAssetStorageAccount, outputAssetOptions)); }
/// <summary> /// Returns a <see cref="IJob"/> instance with a single <see cref="ITask"/> ready to be submitted. /// </summary> /// <param name="jobs">The <see cref="JobBaseCollection"/> instance.</param> /// <param name="mediaProcessorName">The name of the media processor.</param> /// <param name="taskConfiguration">The task configuration.</param> /// <param name="inputAsset">The input <see cref="IAsset"/> instance.</param> /// <param name="outputAssetName">The name of the output asset.</param> /// <param name="outputAssetStorageAccountName">The name of the Storage Account where to store the output asset.</param> /// <param name="outputAssetOptions">The <see cref="AssetCreationOptions"/> of the output asset.</param> /// <returns>A <see cref="IJob"/> instance with a single <see cref="ITask"/> ready to be submitted.</returns> public static IJob CreateWithSingleTask(this JobBaseCollection jobs, string mediaProcessorName, string taskConfiguration, IAsset inputAsset, string outputAssetName, string outputAssetStorageAccountName, AssetCreationOptions outputAssetOptions) { if (jobs == null) { throw new ArgumentNullException("jobs", "The jobs collection cannot be null."); } if (inputAsset == null) { throw new ArgumentNullException("inputAsset", "The input asset cannot be null."); } MediaContextBase context = jobs.MediaContext; IMediaProcessor processor = context.MediaProcessors.GetLatestMediaProcessorByName(mediaProcessorName); if (processor == null) { throw new ArgumentException( string.Format(CultureInfo.InvariantCulture, "Unknown media processor: '{0}'", mediaProcessorName), "mediaProcessorName"); } IJob job = jobs.Create(string.Format(CultureInfo.InvariantCulture, "Job for {0}", inputAsset.Name)); ITask task = job.Tasks.AddNew( string.Format(CultureInfo.InvariantCulture, "Task for {0}", inputAsset.Name), processor, taskConfiguration, TaskOptions.ProtectedConfiguration); task.InputAssets.Add(inputAsset); if (string.IsNullOrWhiteSpace(outputAssetStorageAccountName)) { outputAssetStorageAccountName = context.DefaultStorageAccount.Name; } task.OutputAssets.AddNew(outputAssetName, outputAssetStorageAccountName, outputAssetOptions); return(job); }
/// <summary> /// Returns a <see cref="IJob"/> instance with a single <see cref="ITask"/> ready to be submitted. /// </summary> /// <param name="jobs">The <see cref="JobBaseCollection"/> instance.</param> /// <param name="mediaProcessorName">The name of the media processor.</param> /// <param name="taskConfiguration">The task configuration.</param> /// <param name="inputAsset">The input <see cref="IAsset"/> instance.</param> /// <param name="outputAssetName">The name of the output asset.</param> /// <param name="outputAssetOptions">The <see cref="AssetCreationOptions"/> of the output asset.</param> /// <returns>A <see cref="IJob"/> instance with a single <see cref="ITask"/> ready to be submitted.</returns> public static IJob CreateWithSingleTask(this JobBaseCollection jobs, string mediaProcessorName, string taskConfiguration, IAsset inputAsset, string outputAssetName, AssetCreationOptions outputAssetOptions) { return(jobs.CreateWithSingleTask(mediaProcessorName, taskConfiguration, inputAsset, outputAssetName, null, outputAssetOptions)); }