Exemple #1
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));
        }
Exemple #2
0
        private IDictionary <string, string> GetJobPublish(MediaJobOutputPublish jobOutputPublish)
        {
            Dictionary <string, string> jobPublish = new Dictionary <string, string>();
            string outputPublish = JsonConvert.SerializeObject(jobOutputPublish);
            string mediaAccount  = JsonConvert.SerializeObject(this.MediaAccount);
            string userAccount   = JsonConvert.SerializeObject(this.UserAccount);

            jobPublish.Add(Constant.Media.Job.CorrelationData.OutputPublish, outputPublish);
            jobPublish.Add(Constant.Media.Job.CorrelationData.MediaAccount, mediaAccount);
            jobPublish.Add(Constant.Media.Job.CorrelationData.UserAccount, userAccount);
            return(jobPublish);
        }
Exemple #3
0
        public MediaPublishNotification PublishJobOutput(string transformName, string jobName, string eventType)
        {
            MediaPublishNotification publishNotification = new MediaPublishNotification
            {
                PhoneNumber   = this.UserAccount.MobilePhoneNumber,
                StatusMessage = string.Format(Constant.Message.JobPublishNotification, Constant.TextFormatter.FormatValue(transformName), jobName, eventType)
            };
            Job job = GetEntity <Job>(MediaEntity.TransformJob, jobName, transformName);

            if (job != null)
            {
                switch (eventType)
                {
                case Constant.Media.Job.EventType.Errored:
                    string jobError = null;
                    foreach (JobOutput jobOutput in job.Outputs)
                    {
                        if (!string.IsNullOrEmpty(jobError))
                        {
                            jobError = string.Concat(jobError, Constant.Message.NewLine);
                        }
                        jobError = string.Concat(jobError, jobOutput.Error.Message);
                    }
                    publishNotification.StatusMessage = string.Concat(publishNotification.StatusMessage, Constant.Message.NewLine, jobError);
                    break;

                case Constant.Media.Job.EventType.Finished:
                    string settingKey        = Constant.AppSettingKey.MediaPlayerDemoUrl;
                    string mediaPlayerUrl    = AppSetting.GetValue(settingKey);
                    string outputPublishData = job.CorrelationData[Constant.Media.Job.CorrelationData.OutputPublish].ToString();
                    MediaJobOutputPublish jobOutputPublish = JsonConvert.DeserializeObject <MediaJobOutputPublish>(outputPublishData);
                    foreach (JobOutputAsset jobOutput in job.Outputs)
                    {
                        Asset             outputAsset = GetEntity <Asset>(MediaEntity.Asset, jobOutput.AssetName);
                        StorageBlobClient blobClient  = new StorageBlobClient(this.MediaAccount, outputAsset.StorageAccountName);
                        if (blobClient.ContainsFile(outputAsset.Container, null, null, Constant.Media.Stream.ManifestExtension))
                        {
                            StreamingLocator streamingLocator = GetStreamingLocator(jobOutput.AssetName, jobOutput.AssetName, jobOutputPublish.StreamingPolicyName, jobOutputPublish.ContentProtection);
                            string           mediaStreamUrl   = GetStreamingUrl(streamingLocator, null);
                            mediaStreamUrl = string.Format(mediaPlayerUrl, mediaStreamUrl);
                            publishNotification.StatusMessage = string.Concat(publishNotification.StatusMessage, Constant.Message.NewLine, mediaStreamUrl);
                        }
                    }
                    SetJobInputAssetArchive(job.Input, jobOutputPublish.InputAssetStorageTier);
                    break;
                }
            }
            return(publishNotification);
        }