예제 #1
0
        /// <summary>
        /// Execute tarnscoding process base on profile on configuration
        /// </summary>
        /// <param name="assetToConvert">AMS Asset</param>
        private void ConvertMP4toSmooth(IAsset assetToConvert)
        {
            // Declare a new job to contain the tasks
            string jobName = string.Format("Convert to Smooth Streaming job {0} [{1}]", myAssetOriginal.Name, myRequest.ProcessInstanceId);

            currentJob = _MediaServicesContext.Jobs.Create(jobName);
            // Set up the first Task to convert from MP4 to Smooth Streaming.
            // Read in task configuration XML
            var    encodeData             = getEncodeInformation();
            string EncodingProfileXmlData = encodeData[0];
            string encodingProfileLabel   = encodeData[1];

            // Get a media packager reference

            IMediaProcessor processor = myEncodigSupport.GetLatestMediaProcessorByName("Media Encoder Standard");

            // Create a task with the conversion details, using the configuration data
            ITask task = currentJob.Tasks.AddNew("Task profile " + encodingProfileLabel,
                                                 processor,
                                                 EncodingProfileXmlData,
                                                 TaskOptions.None);

            // Specify the input asset to be converted.
            task.InputAssets.Add(assetToConvert);
            // Add an output asset to contain the results of the job.
            task.OutputAssets.AddNew(assetToConvert.Name + "_mb", AssetCreationOptions.None);
            // Use the following event handler to check job progress.
            // The StateChange method is the same as the one in the previous sample
            //currentJob.StateChanged += new EventHandler<JobStateChangedEventArgs>(StateChanged);
            currentJob.StateChanged += new EventHandler <JobStateChangedEventArgs>(myEncodigSupport.StateChanged);

            //Set advantce on 0%
            string message = "job " + currentJob.Id + " Percent complete: 0%";

            MyEncodigSupport_JobUpdate(message, null);

            // Launch the job.
            currentJob.Submit();

            //8. Idenpotence MARK
            myRequest.MetaData.Add(this.GetType() + "_" + myRequest.ProcessInstanceId, currentJob.Id);
            myStorageManager.PersistProcessStatus(myRequest);

            //9. Check Project Status
            myEncodigSupport.OnJobError += MyEncodigSupport_OnJobError;
            myEncodigSupport.JobUpdate  += MyEncodigSupport_JobUpdate;
            myEncodigSupport.WaitJobFinish(currentJob.Id);
        }
        /// <summary>
        /// Update the status in Track table.
        /// </summary>
        /// <param name="request"></param>
        protected void UpdateProcessStatus(ChainRequest request, string txtInformation)
        {
            Trace.TraceInformation(txtInformation);
            IButlerStorageManager storageManager = BlobManagerFactory.CreateBlobManager(request.ProcessConfigConn);

            storageManager.PersistProcessStatus(request);
        }
예제 #3
0
        private void MyEncodigSupport_JobUpdate(object sender, EventArgs e)
        {
            string message = (string)sender;

            if (!myRequest.MetaData.Any(item => item.Key == Configuration.TranscodingAdvance))
            {
                myRequest.MetaData.Add(Configuration.TranscodingAdvance, message);
            }
            else
            {
                myRequest.MetaData[Configuration.TranscodingAdvance] = message;
            }
            myStorageManager.PersistProcessStatus(myRequest);
        }