Ejemplo n.º 1
0
 public dotControl(string dotControlURL)
 {
     if (!string.IsNullOrEmpty(dotControlURL))
     {
         //
         IButlerStorageManager resource = BlobManagerFactory.CreateBlobManager(dotControlURL);
         jsonControl = resource.ReadTextBlob(dotControlURL);
     }
 }
        public override void HandleExecute(ChainRequest request)
        {
            myRequest   = (ButlerProcessRequest)request;
            blobManager = BlobManagerFactory.CreateBlobManager(myRequest.ProcessConfigConn);

            string jsonControlFile = blobManager.ReadTextBlob(new Uri(myRequest.ButlerRequest.ControlFileUri));

            dotControlConfig = new jsonKeyValue(jsonControlFile);
            if (dotControlConfig.Read(MediaButler.Common.DotControlConfigKeys.httpNotificationStepGetOnFinishUrl) != "")
            {
                //GET
                HttpGetNotification();
            }
            else
            {
                //POST
                HttpPostNotification();
            }
        }
Ejemplo n.º 3
0
        private List <IJobConfiguration> GetJobConfig(string ProcessId, string InputAssetId, string OutPutAssetId)
        {
            List <IJobConfiguration> myJobs = new List <IJobConfiguration>();
            JArray MultiJobTaskEncode       = (JArray)allPorcessData.ReadArray("MultiJobTaskEncode");

            consolidateId = int.Parse(allPorcessData.Read("ConsolidateOutput"));

            for (int i = 0; i < MultiJobTaskEncode.Count(); i++)
            {
                string   ProcessorName   = (string)MultiJobTaskEncode[i]["ProcessorName"];
                string[] ProfileFileList = ((JArray)MultiJobTaskEncode[i]["ProfileFileList"]).ToObject <string[]>();
                string[] FilesToCopy     = ((JArray)MultiJobTaskEncode[i]["FilesToCopy"]).ToObject <string[]>();
                for (int profileId = 0; profileId < ProfileFileList.Count(); profileId++)
                {
                    ProfileFileList[profileId] = myBlobManager.ReadTextBlob("mediabutlerbin", "encoderdefinitions/" + ProfileFileList[profileId]);
                }
                JobConfiguration J = new JobConfiguration(ProcessorName, ProcessId);
                J.AddTask(ProfileFileList, InputAssetId, OutPutAssetId, FilesToCopy);
                myJobs.Add(J);
            }

            return(myJobs);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Set MP4 as primary file
        /// </summary>
        private void setPrimaryFile()
        {
            string     myPrimaryFile = null;
            IAssetFile mp4           = null;


            if (!string.IsNullOrEmpty(myRequest.ButlerRequest.ControlFileUri))
            {
                //
                IButlerStorageManager resource = BlobManagerFactory.CreateBlobManager(myRequest.ProcessConfigConn);
                string jsonControl             = resource.ReadTextBlob(new Uri(myRequest.ButlerRequest.ControlFileUri));
                if (!string.IsNullOrEmpty(jsonControl))
                {
                    IjsonKeyValue myControl = new jsonKeyValue(jsonControl);
                    myPrimaryFile = myControl.Read(DotControlConfigKeys.IngestMultiMezzamineFilesPrimaryFile);
                }
            }

            IEncoderSupport myEncodigSupport = new EncoderSupport(MediaContext);

            if (!string.IsNullOrEmpty(myPrimaryFile))
            {
                mp4 = currentAsset.AssetFiles.Where(f => f.Name.ToLower() == myPrimaryFile.ToLower()).FirstOrDefault();
            }
            if (mp4 == null)
            {
                mp4 = currentAsset.AssetFiles.Where(f => f.Name.ToLower().EndsWith(".mp4")).FirstOrDefault();
            }
            if (mp4 != null)
            {
                myEncodigSupport.SetPrimaryFile(currentAsset, mp4);
            }
            else
            {
                Trace.TraceWarning("{0} setPrimaryFile {2} processId {1}, has not MP4 file", this.GetType().FullName, myRequest.ProcessInstanceId, myRequest.ProcessTypeId);
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Load Encoding profile definition for
        /// </summary>
        /// <returns></returns>
        private string[] getEncodeInformation()
        {
            //default Xml Profile
            string xmlEncodeProfile  = null;
            string encodeProfileName = null;//

            //First priority Process instance level === .Control as part of the package
            if (!string.IsNullOrEmpty(myRequest.ButlerRequest.ControlFileUri))
            {
                string        jsonData = myStorageManager.ReadTextBlob(new Uri(myRequest.ButlerRequest.ControlFileUri));
                IjsonKeyValue x        = new jsonKeyValue(jsonData);
                try
                {
                    encodeProfileName = x.Read(DotControlConfigKeys.StandardEncodigProfileName).ToLower();
                }
                catch (Exception)
                {
                    string txtTrace = string.Format("[{0}] process Type {1} instance {2} Control has not encodigProfile definition ", this.GetType().FullName, myRequest.ProcessTypeId, myRequest.ProcessInstanceId);

                    Trace.TraceWarning(txtTrace);
                }

                if (!string.IsNullOrEmpty(encodeProfileName))
                {
                    try
                    {
                        //Encodig Profile has info

                        string xmlURL = myRequest.ButlerRequest.MezzanineFiles.Where(u => u.ToLower().EndsWith(encodeProfileName)).FirstOrDefault();

                        if (string.IsNullOrEmpty(xmlURL))
                        {
                            //Not custom encodig profile on input package ==> Preset
                            xmlEncodeProfile = myEncodigSupport.LoadEncodeProfile(encodeProfileName, myRequest.ProcessConfigConn);
                        }
                        else
                        {
                            //xmlEncodeProfile = myStorageManager.ReadTextBlob(xmlURL);


                            Uri    xmlURI    = new Uri(xmlURL);
                            string container = xmlURI.Segments[1].Substring(0, xmlURI.Segments[1].Length - 1);
                            CloudStorageAccount storageAccount = CloudStorageAccount.Parse(myRequest.ProcessConfigConn);
                            CloudBlobClient     blobClient     = storageAccount.CreateCloudBlobClient();
                            CloudBlobContainer  containerX     = blobClient.GetContainerReference(container);
                            CloudBlockBlob      blockBlob      = containerX.GetBlockBlobReference(xmlURI.Segments[2] + xmlURI.Segments[3] + xmlURI.Segments[4]);
                            if (blockBlob.Exists())
                            {
                                //Trace.TraceInformation("[{0}] process Type {1} instance {2} Encoder Profile {3} from Blob Storage", this.GetType().FullName, myRequest.ProcessTypeId, myRequest.ProcessInstanceId, profileInfo);

                                using (var memoryStream = new MemoryStream())
                                {
                                    blockBlob.DownloadToStream(memoryStream);
                                    memoryStream.Position = 0;
                                    StreamReader sr = new StreamReader(memoryStream, System.Text.Encoding.ASCII);
                                    xmlEncodeProfile = sr.ReadToEnd();
                                }
                            }
                        }
                    }
                    catch (Exception)
                    {
                        xmlEncodeProfile = null;
                        string txt = string.Format("StandarEncodeStep try to read XMl profile from control but it is  {0} ", DateTime.Now.ToString());
                        Trace.TraceWarning(txt);
                    }
                }
            }
            //Second option is Process Level === Configuration
            if (xmlEncodeProfile == null)
            {
                if (!string.IsNullOrEmpty(this.StepConfiguration))
                {
                    encodeProfileName = this.StepConfiguration;
                }
                else
                {
                    encodeProfileName = "H264 Multiple Bitrate 1080p.json";
                }

                // xmlEncodeProfile = LoadEncodeProfile(encodeProfileName);
                xmlEncodeProfile = myEncodigSupport.LoadEncodeProfile(encodeProfileName, myRequest.ProcessConfigConn);
            }

            return(new string[2] {
                xmlEncodeProfile, encodeProfileName
            });
        }