Exemplo n.º 1
0
 private void SetOutputAssetLink(MediaTransformPreset[] transformPresets, JobOutputAsset[] jobOutputs, MediaJobOutputInsight outputInsight)
 {
     if (transformPresets.Length > 1 || !string.IsNullOrEmpty(outputInsight.Id))
     {
         string encodingOutputAssetName = null;
         Dictionary <MediaTransformPreset, string> jobOutputAssets = new Dictionary <MediaTransformPreset, string>();
         for (int i = 0; i < transformPresets.Length; i++)
         {
             MediaTransformPreset transformPreset = transformPresets[i];
             if (transformPreset == MediaTransformPreset.AdaptiveStreaming || transformPreset == MediaTransformPreset.ContentAwareEncoding)
             {
                 encodingOutputAssetName = jobOutputs[i].AssetName;
             }
             else
             {
                 jobOutputAssets.Add(transformPreset, jobOutputs[i].AssetName);
             }
         }
         if (!string.IsNullOrEmpty(outputInsight.Id))
         {
             if (outputInsight.VideoIndexer)
             {
                 jobOutputAssets.Add(MediaTransformPreset.VideoIndexer, outputInsight.Id);
             }
             if (outputInsight.AudioIndexer)
             {
                 jobOutputAssets.Add(MediaTransformPreset.AudioIndexer, outputInsight.Id);
             }
         }
         if (!string.IsNullOrEmpty(encodingOutputAssetName))
         {
             MediaAssetLink assetLink = new MediaAssetLink()
             {
                 AssetName    = encodingOutputAssetName,
                 JobOutputs   = jobOutputAssets,
                 MediaAccount = this.MediaAccount,
                 UserAccount  = this.UserAccount
             };
             using (DatabaseClient databaseClient = new DatabaseClient(true))
             {
                 string collectionId = Constant.Database.Collection.MediaAssets;
                 databaseClient.UpsertDocument(collectionId, assetLink);
             }
         }
     }
 }
Exemplo n.º 2
0
        public Job CreateJob(string transformName, string jobName, string jobDescription, Priority jobPriority, string inputFileUrl, Asset inputAsset,
                             string outputAssetStorage, MediaJobOutputPublish outputPublish, MediaJobOutputInsight outputInsight, bool setEventGrid)
        {
            if (setEventGrid)
            {
                EventGridClient.SetMediaSubscription(this.MediaAccount);
            }
            if (string.IsNullOrEmpty(jobName))
            {
                jobName = Guid.NewGuid().ToString();
            }
            MediaJob mediaJob = new MediaJob()
            {
                Name               = jobName,
                Description        = jobDescription,
                Priority           = jobPriority,
                InputFileUrl       = inputFileUrl,
                InputAsset         = inputAsset,
                OutputAssetStorage = outputAssetStorage,
                OutputPublish      = outputPublish,
                OutputInsight      = outputInsight
            };

            return(CreateJob(transformName, mediaJob));
        }