Esempio n. 1
0
        public Job CreateJob(string authToken, string transformName, string jobName, string jobDescription, Priority jobPriority,
                             string jobData, string inputFileUrl, string inputAssetName, MediaJobOutputMode outputAssetMode,
                             string[] outputAssetDescriptions, string[] outputAssetAlternateIds, string streamingPolicyName)
        {
            JObject  jobPublish = GetJobPublish(authToken, jobData, streamingPolicyName);
            MediaJob mediaJob   = new MediaJob()
            {
                Name                    = jobName,
                Description             = jobDescription,
                Priority                = jobPriority,
                Data                    = jobPublish,
                InputFileUrl            = inputFileUrl,
                InputAssetName          = inputAssetName,
                OutputAssetMode         = outputAssetMode,
                OutputAssetDescriptions = outputAssetDescriptions,
                OutputAssetAlternateIds = outputAssetAlternateIds
            };
            Job             job        = CreateJob(transformName, mediaJob);
            MediaJobAccount jobAccount = new MediaJobAccount()
            {
                JobName       = job.Name,
                TransformName = transformName,
                MediaAccount  = MediaAccount
            };

            using (DatabaseClient databaseClient = new DatabaseClient())
            {
                string collectionId = Constant.Database.Collection.MediaJobAccount;
                databaseClient.UpsertDocument(collectionId, jobAccount);
            }
            return(job);
        }
Esempio n. 2
0
        private void SetJobAccount(string insightId)
        {
            MediaJobAccount jobAccount = new MediaJobAccount()
            {
                JobName      = insightId,
                MediaAccount = MediaAccount
            };

            using (DatabaseClient databaseClient = new DatabaseClient())
            {
                string collectionId = Constant.Database.Collection.MediaJobAccount;
                databaseClient.UpsertDocument(collectionId, jobAccount);
            }
        }
Esempio n. 3
0
        public static MediaJobPublish PublishJobOutput(string jobName, string insightId)
        {
            MediaJobAccount jobAccount;
            MediaJobPublish jobPublish = null;

            using (DatabaseClient databaseClient = new DatabaseClient())
            {
                string collectionId = Constant.Database.Collection.MediaJobAccount;
                string documentId   = string.IsNullOrEmpty(jobName) ? insightId : jobName;
                jobAccount = databaseClient.GetDocument <MediaJobAccount>(collectionId, documentId);
            }
            if (jobAccount != null)
            {
                using (MediaClient mediaClient = new MediaClient(null, jobAccount.MediaAccount))
                {
                    if (!string.IsNullOrEmpty(insightId))
                    {
                        JObject insight = mediaClient.IndexerGetInsight(insightId);
                        if (insight != null)
                        {
                            using (DatabaseClient databaseClient = new DatabaseClient())
                            {
                                string collectionId = Constant.Database.Collection.MediaContentInsight;
                                databaseClient.UpsertDocument(collectionId, insight);
                            }
                        }
                    }
                    else
                    {
                        Job job = mediaClient.GetEntity <Job>(MediaEntity.TransformJob, jobName, jobAccount.TransformName);
                        if (job != null)
                        {
                            jobPublish = GetJobPublish(job);
                            jobPublish.UserNotification.JobOutputMessage = GetNotificationMessage(job, jobAccount, jobPublish);
                            string streamingPolicyName = PredefinedStreamingPolicy.ClearStreamingOnly;
                            if (!string.IsNullOrEmpty(jobPublish.StreamingPolicyName))
                            {
                                streamingPolicyName = jobPublish.StreamingPolicyName;
                            }
                            foreach (JobOutputAsset jobOutput in job.Outputs)
                            {
                                mediaClient.CreateLocator(jobOutput.AssetName, jobOutput.AssetName, streamingPolicyName, jobPublish.ContentProtection);
                            }
                        }
                    }
                }
            }
            return(jobPublish);
        }
Esempio n. 4
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);
             }
         }
     }
 }