public void JobJobProgressRequest() { Output output = new Output() { Label = "iPhone", Url = "s3://output-bucket/output-file-1-name.mp4", Width = 480, Height = 320 }; CreateJobResponse createResponse = Zencoder.CreateJob("s3://bucket-name/file-name.avi", new Output[] { output }); Assert.IsTrue(createResponse.Success); JobProgressResponse progressResponse = Zencoder.JobProgress(createResponse.Outputs.First().Id); Assert.IsTrue(progressResponse.Success); AutoResetEvent[] handles = new AutoResetEvent[] { new AutoResetEvent(false) }; Zencoder.JobProgress( createResponse.Outputs.First().Id, r => { Assert.IsTrue(r.Success); handles[0].Set(); }); WaitHandle.WaitAll(handles); }
public void JobDeleteJobRequest() { CreateJobResponse createResponse = Zencoder.CreateJob("s3://bucket-name/file-name.avi", null, null, null, true, false); Assert.IsTrue(createResponse.Success); // TODO: Investigate whether Zencoder has truly deprecated this API operation. // For now, just test for an InConflict status, because that's what it seems // we should expect. DeleteJobResponse deleteResponse = Zencoder.DeleteJob(createResponse.Id); Assert.IsTrue(deleteResponse.InConflict); AutoResetEvent[] handles = new AutoResetEvent[] { new AutoResetEvent(false) }; Zencoder.DeleteJob( createResponse.Id, r => { Assert.IsTrue(r.InConflict); handles[0].Set(); }); WaitHandle.WaitAll(handles); }
public void JobCancelJobRequest() { CreateJobResponse createResponse = Zencoder.CreateJob("s3://bucket-name/file-name.avi", null, null, null, true, false); Assert.IsTrue(createResponse.Success); CancelJobResponse cancelResponse = Zencoder.CancelJob(createResponse.Id); Assert.IsTrue(cancelResponse.Success); }
public void OutputH264CreateJob() { Output output = new Output() { H264Level = H264Level.FourPointOne, H264ReferenceFrames = 5, H264Profile = H264Profile.High, Tuning = Tuning.FastDecode }; CreateJobResponse response = Zencoder.CreateJob("s3://bucket-name/file-name.avi", new Output[] { output }); Assert.IsTrue(response.Success); }
public void JobNestedAsyncRequests() { ManualResetEvent[] handles = new ManualResetEvent[] { new ManualResetEvent(false), new ManualResetEvent(false) }; // Nested async calls. Zencoder.CreateJob( "s3://bucket-name/file-name.avi", null, 3, "asia", true, false, r => { Assert.IsTrue(r.Success); Zencoder.JobDetails( r.Id, dr => { Assert.IsTrue(dr.Success); handles[0].Set(); }); }); // Async call then a sync call. Zencoder.CreateJob( "s3://bucket-name/file-name.avi", null, 3, "asia", true, false, r => { Assert.IsTrue(r.Success); Assert.IsTrue(Zencoder.JobDetails(r.Id).Success); handles[1].Set(); }); foreach (var handle in handles) { handle.WaitOne(); } }
public void JobCreateJobRequest() { Output[] outputs = new Output[] { new Output() { Label = "iPhone", Url = "s3://output-bucket/output-file-1-name.mp4", Width = 480, Height = 320 }, new Output() { Label = "WebHD", Url = "s3://output-bucket/output-file-2-name.mp4", Width = 1280, Height = 720 } }; CreateJobResponse response = Zencoder.CreateJob("s3://bucket-name/file-name.avi", outputs, null, null, true); Assert.IsTrue(response.Success); Assert.IsTrue(response.Id > 0); Assert.AreEqual(outputs.Count(), response.Outputs.Count()); Assert.IsTrue(response.Outputs.First().Id > 0); AutoResetEvent[] handles = new AutoResetEvent[] { new AutoResetEvent(false) }; Zencoder.CreateJob( "s3://bucket-name/file-name.avi", null, 3, "asia", true, r => { Assert.IsTrue(r.Success); Assert.IsTrue(r.Id > 0); Assert.IsTrue(r.Outputs.Count() > 0); Assert.IsTrue(r.Outputs.First().Id > 0); handles[0].Set(); }); WaitHandle.WaitAll(handles); }
public void JobResubmitJobRequest() { CreateJobResponse createResponse = Zencoder.CreateJob("s3://bucket-name/file-name.avi", null, null, null, true); Assert.IsTrue(createResponse.Success); ResubmitJobResponse resubmitResponse = Zencoder.ResubmitJob(createResponse.Id); Assert.IsTrue(resubmitResponse.Success); AutoResetEvent[] handles = new AutoResetEvent[] { new AutoResetEvent(false) }; Zencoder.ResubmitJob( createResponse.Id, r => { Assert.IsTrue(r.Success); handles[0].Set(); }); WaitHandle.WaitAll(handles); }
public void JobDeleteJobRequest() { CreateJobResponse createResponse = Zencoder.CreateJob("s3://bucket-name/file-name.avi", null, null, null, true); Assert.IsTrue(createResponse.Success); DeleteJobResponse deleteResponse = Zencoder.DeleteJob(createResponse.Id); Assert.IsTrue(deleteResponse.Success); AutoResetEvent[] handles = new AutoResetEvent[] { new AutoResetEvent(false) }; Zencoder.DeleteJob( createResponse.Id, r => { Assert.IsTrue(r.StatusCode == HttpStatusCode.NotFound); handles[0].Set(); }); WaitHandle.WaitAll(handles); }
public void JobCancelJobRequestAsync() { CreateJobResponse createResponse = Zencoder.CreateJob("s3://bucket-name/file-name.avi", null, null, null, true, false); Assert.IsTrue(createResponse.Success); AutoResetEvent[] handles = new AutoResetEvent[] { new AutoResetEvent(false) }; CancelJobResponse asyncResponse = null; Zencoder.CancelJob( createResponse.Id, r => { asyncResponse = r; handles[0].Set(); }); WaitHandle.WaitAll(handles); Assert.IsNotNull(asyncResponse); Assert.IsTrue(asyncResponse.Success); }