diff --git a/Source/Zencoder.Test/Zencoder.Test.csproj b/Source/Zencoder.Test/Zencoder.Test.csproj index 0c49eb2..e3412b3 100644 --- a/Source/Zencoder.Test/Zencoder.Test.csproj +++ b/Source/Zencoder.Test/Zencoder.Test.csproj @@ -54,7 +54,7 @@ bin\Release\Zencoder.Test.xml - + False ..\..\Lib\Moq.dll diff --git a/Source/Zencoder/AccountIntegrationModeRequest.cs b/Source/Zencoder/AccountIntegrationModeRequest.cs index 02db9e6..6067c08 100644 --- a/Source/Zencoder/AccountIntegrationModeRequest.cs +++ b/Source/Zencoder/AccountIntegrationModeRequest.cs @@ -58,7 +58,7 @@ public override Uri Url /// public override string Verb { - get { return "GET"; } + get { return "PUT"; } } /// diff --git a/Source/Zencoder/CancelJobRequest.cs b/Source/Zencoder/CancelJobRequest.cs index d6bd6ef..0c59d66 100644 --- a/Source/Zencoder/CancelJobRequest.cs +++ b/Source/Zencoder/CancelJobRequest.cs @@ -83,7 +83,7 @@ public override Uri Url /// public override string Verb { - get { return "GET"; } + get { return "PUT"; } } } } diff --git a/Source/Zencoder/CreateJobRequest.cs b/Source/Zencoder/CreateJobRequest.cs index 9e9a4f3..68edf79 100644 --- a/Source/Zencoder/CreateJobRequest.cs +++ b/Source/Zencoder/CreateJobRequest.cs @@ -63,6 +63,12 @@ public CreateJobRequest(string apiKey, Uri baseUrl) [JsonProperty("outputs", NullValueHandling = NullValueHandling.Ignore)] public Output[] Outputs { get; set; } + /// + /// Gets or sets the pass_through value for the job. + /// + [JsonProperty("pass_through", DefaultValueHandling = DefaultValueHandling.Ignore, NullValueHandling = NullValueHandling.Ignore)] + public string PassThrough { get; set; } + /// /// Gets or sets the region to use when processing the job. /// Defaults to "us". diff --git a/Source/Zencoder/HttpPostNotification.cs b/Source/Zencoder/HttpPostNotification.cs index 129cad3..4b1bede 100644 --- a/Source/Zencoder/HttpPostNotification.cs +++ b/Source/Zencoder/HttpPostNotification.cs @@ -26,5 +26,13 @@ public class HttpPostNotification /// [JsonProperty("output")] public HttpPostNotificationOutput Output { get; set; } + + /// + /// Gets or sets the job's output the notification relates to. + /// + [JsonProperty("input")] + public HttpPostNotificationInput Input { get; set; } + + } } diff --git a/Source/Zencoder/HttpPostNotificationInput.cs b/Source/Zencoder/HttpPostNotificationInput.cs new file mode 100644 index 0000000..90aea70 --- /dev/null +++ b/Source/Zencoder/HttpPostNotificationInput.cs @@ -0,0 +1,66 @@ +//----------------------------------------------------------------------- +// +// Copyright (c) 2013 Chad Burggraf, Adam Rogas +// +//----------------------------------------------------------------------- + +namespace Zencoder +{ + using System; + using Newtonsoft.Json; + + /// + /// Represents a job output in an . + /// + [JsonObject(MemberSerialization = MemberSerialization.OptIn)] + public class HttpPostNotificationInput + { + /// + /// Gets or sets the output's ID. + /// + [JsonProperty("id")] + public int Id { get; set; } + + /// + /// Gets or sets the output's label, if applicable. + /// + [JsonProperty("label")] + public string Label { get; set; } + + /// + /// Gets or sets the input's height, if applicable. + /// + [JsonProperty("height")] + public int Height { get; set; } + + /// + /// Gets or sets the input's width, if applicable. + /// + [JsonProperty("width")] + public int Width { get; set; } + + /// + /// Gets or sets the input's file size, if applicable. + /// + [JsonProperty("file_size_in_bytes")] + public long FileSize { get; set; } + + /// + /// Gets or sets the input's duration, if applicable. + /// + [JsonProperty("duration_in_ms")] + public long Duration { get; set; } + + /// + /// Gets or sets the output's state. + /// + [JsonProperty("state")] + public InputState State { get; set; } + + /// + /// Gets or sets the output's URL. + /// + [JsonProperty("url")] + public string Url { get; set; } + } +} diff --git a/Source/Zencoder/HttpPostNotificationJob.cs b/Source/Zencoder/HttpPostNotificationJob.cs index 871d386..c2d9ef0 100644 --- a/Source/Zencoder/HttpPostNotificationJob.cs +++ b/Source/Zencoder/HttpPostNotificationJob.cs @@ -21,6 +21,12 @@ public class HttpPostNotificationJob [JsonProperty("id")] public int Id { get; set; } + /// + /// Gets or sets the job pass through value. + /// + [JsonProperty("pass_through")] + public string PassThrough { get; set; } + /// /// Gets or sets the job state. /// diff --git a/Source/Zencoder/MediaFileFormat.cs b/Source/Zencoder/MediaFileFormat.cs index e8884f7..f44f1dc 100644 --- a/Source/Zencoder/MediaFileFormat.cs +++ b/Source/Zencoder/MediaFileFormat.cs @@ -22,6 +22,12 @@ public enum MediaFileFormat [Description("mp4")] MPFour = 0, + /// + /// Identifies the AAC format. + /// + [Description("aac")] + AAC, + /// /// Identifies the 3G2 format. /// diff --git a/Source/Zencoder/Output.cs b/Source/Zencoder/Output.cs index 82745db..b010405 100644 --- a/Source/Zencoder/Output.cs +++ b/Source/Zencoder/Output.cs @@ -114,6 +114,20 @@ public class Output [JsonConverter(typeof(BooleanConverter))] public bool? ConstantBitrate { get; set; } + /// + /// Gets or sets a value indicating whether to copy the input audio track, if one is present. + /// + [JsonProperty("copy_audio", NullValueHandling = NullValueHandling.Ignore)] + [JsonConverter(typeof(BooleanConverter))] + public bool? CopyAudio { get; set; } + + /// + /// Gets or sets a value indicating whether to copy the input audio track, if one is present. + /// + [JsonProperty("copy_video", NullValueHandling = NullValueHandling.Ignore)] + [JsonConverter(typeof(BooleanConverter))] + public bool? CopyVideo { get; set; } + /// /// Gets or sets a value indicating whether to apply a deblocking filter to the output video. /// @@ -313,6 +327,14 @@ public IDictionary Headers [JsonProperty("segment_seconds", NullValueHandling = NullValueHandling.Ignore)] public int? SegmentSeconds { get; set; } + /// + /// Gets or sets the maximum duration to use for each segment in segmented outputs. + /// + [JsonProperty("segment_video_snapshots", NullValueHandling = NullValueHandling.Ignore)] + [JsonConverter(typeof(BooleanConverter))] + public bool? SegmentVideoSnapshots { get; set; } + + /// /// Gets or sets a value indicating whether to apply a sharpen filter to the output video. /// @@ -320,6 +342,12 @@ public IDictionary Headers [JsonConverter(typeof(BooleanConverter))] public bool? Sharpen { get; set; } + /// + /// Gets or sets the source of the video by label + /// + [JsonProperty("source", DefaultValueHandling = DefaultValueHandling.Ignore, NullValueHandling = NullValueHandling.Ignore)] + public string Source { get; set; } + /// /// Gets or sets a value indicating whether to skip the input audio track, if one is present. /// diff --git a/Source/Zencoder/Request{TRequest,TResponse}.cs b/Source/Zencoder/Request{TRequest,TResponse}.cs index 0eabc50..9091b7e 100644 --- a/Source/Zencoder/Request{TRequest,TResponse}.cs +++ b/Source/Zencoder/Request{TRequest,TResponse}.cs @@ -59,7 +59,7 @@ public virtual TResponse GetResponse() { HttpWebRequest request = this.CreateRequest(); - if ("POST".Equals(this.Verb, StringComparison.OrdinalIgnoreCase)) + if ("POST".Equals(this.Verb, StringComparison.OrdinalIgnoreCase) || "PUT".Equals(this.Verb, StringComparison.OrdinalIgnoreCase)) { using (Stream stream = request.GetRequestStream()) { @@ -91,7 +91,7 @@ public virtual void GetResponseAsync(Action callback) { HttpWebRequest request = this.CreateRequest(); - if ("POST".Equals(this.Verb, StringComparison.OrdinalIgnoreCase)) + if ("POST".Equals(this.Verb, StringComparison.OrdinalIgnoreCase) || "PUT".Equals(this.Verb, StringComparison.OrdinalIgnoreCase)) { request.BeginGetRequestStream( new AsyncCallback( diff --git a/Source/Zencoder/Response.cs b/Source/Zencoder/Response.cs index f10836d..cf6b49b 100644 --- a/Source/Zencoder/Response.cs +++ b/Source/Zencoder/Response.cs @@ -46,7 +46,15 @@ public string[] Errors /// public virtual bool Success { - get { return this.RequestException == null && this.StatusCode == HttpStatusCode.OK; } + get { return this.RequestException == null && (this.StatusCode == HttpStatusCode.OK || this.StatusCode == HttpStatusCode.NoContent); } + } + + /// + /// Gets a value indicating whether the request was successful but returned no content. + /// + public virtual bool NoContent + { + get { return this.RequestException == null && this.StatusCode == HttpStatusCode.NoContent; } } /// diff --git a/Source/Zencoder/ResubmitJobRequest.cs b/Source/Zencoder/ResubmitJobRequest.cs index 0c2e056..a454bd4 100644 --- a/Source/Zencoder/ResubmitJobRequest.cs +++ b/Source/Zencoder/ResubmitJobRequest.cs @@ -60,7 +60,7 @@ public int JobId /// public override Uri Url { - get + get { if (this.url == null) { @@ -69,7 +69,7 @@ public override Uri Url throw new InvalidOperationException("JobId must be set before generating the request URL."); } - this.url = BaseUrl.AppendPath(string.Concat("jobs/", this.JobId)).WithApiKey(ApiKey); + this.url = BaseUrl.AppendPath(String.Format("jobs/{0}/resubmit", this.JobId)).WithApiKey(ApiKey); } return this.url; @@ -81,7 +81,7 @@ public override Uri Url /// public override string Verb { - get { return "GET"; } + get { return "PUT"; } } } } diff --git a/Source/Zencoder/Zencoder.cs b/Source/Zencoder/Zencoder.cs index 62ef3ea..bec40c2 100644 --- a/Source/Zencoder/Zencoder.cs +++ b/Source/Zencoder/Zencoder.cs @@ -23,7 +23,7 @@ public class Zencoder /// /// Gets the default API base URL. /// - public static readonly Uri ServiceUrl = new Uri("https://app.zencoder.com/api/v1"); + public static readonly Uri ServiceUrl = new Uri("https://app.zencoder.com/api/v2"); /// /// Initializes a new instance of the Zencoder class. @@ -273,6 +273,32 @@ public CreateJobResponse CreateJob(string input, IEnumerable outputs, in return request.WithOutputs(outputs).GetResponse(); } + /// + /// A blocking create job request/response cycle. + /// + /// The URL of the input file. + /// The output definition collection. + /// The number of download connections to use when fetching the input file. + /// The region to perform the job in. + /// A value indicating whether to use test mode. + /// A value indicating whether to mock the response rather than actually creating a job. + /// A value that will be passed along and stored with the request. + /// The call response. + public CreateJobResponse CreateJob(string input, IEnumerable outputs, int? downloadConnections, string region, bool? test, bool? mock, string passThrough) + { + CreateJobRequest request = new CreateJobRequest(this) + { + DownloadConnections = downloadConnections, + Input = input, + Mock = mock, + Region = region, + Test = test, + PassThrough = passThrough + }; + + return request.WithOutputs(outputs).GetResponse(); + } + /// /// A blocking create job request/response cycle. /// @@ -297,6 +323,33 @@ public void CreateJob(string input, IEnumerable outputs, int? downloadCo request.WithOutputs(outputs).GetResponseAsync(callback); } + /// + /// A blocking create job request/response cycle. + /// + /// The URL of the input file. + /// The output definition collection. + /// The number of download connections to use when fetching the input file. + /// The region to perform the job in. + /// A value indicating whether to use test mode. + /// A value indicating whether to mock the response rather than actually creating a job. + /// A value that will be passed along and stored with the request. + /// The call response. + public void CreateJob(string input, IEnumerable outputs, int? downloadConnections, string region, bool? test, bool? mock, string passThrough, Action callback) + { + CreateJobRequest request = new CreateJobRequest(this) + { + DownloadConnections = downloadConnections, + Input = input, + Mock = mock, + Region = region, + Test = test, + PassThrough = passThrough + }; + + request.WithOutputs(outputs).GetResponseAsync(callback); + } + + /// /// A blocking delete job request/response cycle. /// diff --git a/Source/Zencoder/Zencoder.csproj b/Source/Zencoder/Zencoder.csproj index deeacd0..031b772 100644 --- a/Source/Zencoder/Zencoder.csproj +++ b/Source/Zencoder/Zencoder.csproj @@ -91,8 +91,9 @@ - + +