Пример #1
0
 private static void PublishAsset(MediaClient mediaClient, IAsset asset, ContentProtection contentProtection)
 {
     if (asset.IsStreamable)
     {
         string          locatorId   = null;
         LocatorType     locatorType = LocatorType.OnDemandOrigin;
         List <ILocator> locators    = asset.Locators.Where(l => l.Type == locatorType).ToList();
         foreach (ILocator locator in locators)
         {
             if (locatorId == null)
             {
                 locatorId = locator.Id;
             }
             locator.Delete();
         }
         List <IAssetDeliveryPolicy> deliveryPolicies = asset.DeliveryPolicies.ToList();
         foreach (IAssetDeliveryPolicy deliveryPolicy in deliveryPolicies)
         {
             asset.DeliveryPolicies.Remove(deliveryPolicy);
         }
         if (contentProtection != null)
         {
             mediaClient.AddDeliveryPolicies(asset, contentProtection);
         }
         mediaClient.CreateLocator(locatorId, locatorType, asset, false);
     }
 }
Пример #2
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);
        }
Пример #3
0
 internal static void PublishStream(MediaClient mediaClient, IAsset asset, ContentProtection contentProtection)
 {
     if (asset.IsStreamable || asset.AssetType == AssetType.MP4)
     {
         if (asset.Options == AssetCreationOptions.StorageEncrypted && asset.DeliveryPolicies.Count == 0)
         {
             mediaClient.AddDeliveryPolicies(asset, contentProtection);
         }
         if (asset.Locators.Count == 0)
         {
             LocatorType locatorType = LocatorType.OnDemandOrigin;
             mediaClient.CreateLocator(null, locatorType, asset, null);
         }
     }
 }