Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Source/Zencoder.Test/Zencoder.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
<DocumentationFile>bin\Release\Zencoder.Test.xml</DocumentationFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
<Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
<Reference Include="Moq, Version=3.1.416.3, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\Lib\Moq.dll</HintPath>
Expand Down
2 changes: 1 addition & 1 deletion Source/Zencoder/AccountIntegrationModeRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public override Uri Url
/// </summary>
public override string Verb
{
get { return "GET"; }
get { return "PUT"; }
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion Source/Zencoder/CancelJobRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public override Uri Url
/// </summary>
public override string Verb
{
get { return "GET"; }
get { return "PUT"; }
}
}
}
6 changes: 6 additions & 0 deletions Source/Zencoder/CreateJobRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ public CreateJobRequest(string apiKey, Uri baseUrl)
[JsonProperty("outputs", NullValueHandling = NullValueHandling.Ignore)]
public Output[] Outputs { get; set; }

/// <summary>
/// Gets or sets the pass_through value for the job.
/// </summary>
[JsonProperty("pass_through", DefaultValueHandling = DefaultValueHandling.Ignore, NullValueHandling = NullValueHandling.Ignore)]
public string PassThrough { get; set; }

/// <summary>
/// Gets or sets the region to use when processing the job.
/// Defaults to "us".
Expand Down
8 changes: 8 additions & 0 deletions Source/Zencoder/HttpPostNotification.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,13 @@ public class HttpPostNotification
/// </summary>
[JsonProperty("output")]
public HttpPostNotificationOutput Output { get; set; }

/// <summary>
/// Gets or sets the job's output the notification relates to.
/// </summary>
[JsonProperty("input")]
public HttpPostNotificationInput Input { get; set; }


}
}
66 changes: 66 additions & 0 deletions Source/Zencoder/HttpPostNotificationInput.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
//-----------------------------------------------------------------------
// <copyright file="HttpPostNotificationIutput.cs" company="Tasty Codes">
// Copyright (c) 2013 Chad Burggraf, Adam Rogas
// </copyright>
//-----------------------------------------------------------------------

namespace Zencoder
{
using System;
using Newtonsoft.Json;

/// <summary>
/// Represents a job output in an <see cref="HttpPostNotification"/>.
/// </summary>
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
public class HttpPostNotificationInput
{
/// <summary>
/// Gets or sets the output's ID.
/// </summary>
[JsonProperty("id")]
public int Id { get; set; }

/// <summary>
/// Gets or sets the output's label, if applicable.
/// </summary>
[JsonProperty("label")]
public string Label { get; set; }

/// <summary>
/// Gets or sets the input's height, if applicable.
/// </summary>
[JsonProperty("height")]
public int Height { get; set; }

/// <summary>
/// Gets or sets the input's width, if applicable.
/// </summary>
[JsonProperty("width")]
public int Width { get; set; }

/// <summary>
/// Gets or sets the input's file size, if applicable.
/// </summary>
[JsonProperty("file_size_in_bytes")]
public long FileSize { get; set; }

/// <summary>
/// Gets or sets the input's duration, if applicable.
/// </summary>
[JsonProperty("duration_in_ms")]
public long Duration { get; set; }

/// <summary>
/// Gets or sets the output's state.
/// </summary>
[JsonProperty("state")]
public InputState State { get; set; }

/// <summary>
/// Gets or sets the output's URL.
/// </summary>
[JsonProperty("url")]
public string Url { get; set; }
}
}
6 changes: 6 additions & 0 deletions Source/Zencoder/HttpPostNotificationJob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ public class HttpPostNotificationJob
[JsonProperty("id")]
public int Id { get; set; }

/// <summary>
/// Gets or sets the job pass through value.
/// </summary>
[JsonProperty("pass_through")]
public string PassThrough { get; set; }

/// <summary>
/// Gets or sets the job state.
/// </summary>
Expand Down
6 changes: 6 additions & 0 deletions Source/Zencoder/MediaFileFormat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ public enum MediaFileFormat
[Description("mp4")]
MPFour = 0,

/// <summary>
/// Identifies the AAC format.
/// </summary>
[Description("aac")]
AAC,

/// <summary>
/// Identifies the 3G2 format.
/// </summary>
Expand Down
28 changes: 28 additions & 0 deletions Source/Zencoder/Output.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,20 @@ public class Output
[JsonConverter(typeof(BooleanConverter))]
public bool? ConstantBitrate { get; set; }

/// <summary>
/// Gets or sets a value indicating whether to copy the input audio track, if one is present.
/// </summary>
[JsonProperty("copy_audio", NullValueHandling = NullValueHandling.Ignore)]
[JsonConverter(typeof(BooleanConverter))]
public bool? CopyAudio { get; set; }

/// <summary>
/// Gets or sets a value indicating whether to copy the input audio track, if one is present.
/// </summary>
[JsonProperty("copy_video", NullValueHandling = NullValueHandling.Ignore)]
[JsonConverter(typeof(BooleanConverter))]
public bool? CopyVideo { get; set; }

/// <summary>
/// Gets or sets a value indicating whether to apply a deblocking filter to the output video.
/// </summary>
Expand Down Expand Up @@ -313,13 +327,27 @@ public IDictionary<string, string> Headers
[JsonProperty("segment_seconds", NullValueHandling = NullValueHandling.Ignore)]
public int? SegmentSeconds { get; set; }

/// <summary>
/// Gets or sets the maximum duration to use for each segment in segmented outputs.
/// </summary>
[JsonProperty("segment_video_snapshots", NullValueHandling = NullValueHandling.Ignore)]
[JsonConverter(typeof(BooleanConverter))]
public bool? SegmentVideoSnapshots { get; set; }


/// <summary>
/// Gets or sets a value indicating whether to apply a sharpen filter to the output video.
/// </summary>
[JsonProperty("sharpet", NullValueHandling = NullValueHandling.Ignore)]
[JsonConverter(typeof(BooleanConverter))]
public bool? Sharpen { get; set; }

/// <summary>
/// Gets or sets the source of the video by label
/// </summary>
[JsonProperty("source", DefaultValueHandling = DefaultValueHandling.Ignore, NullValueHandling = NullValueHandling.Ignore)]
public string Source { get; set; }

/// <summary>
/// Gets or sets a value indicating whether to skip the input audio track, if one is present.
/// </summary>
Expand Down
4 changes: 2 additions & 2 deletions Source/Zencoder/Request{TRequest,TResponse}.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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())
{
Expand Down Expand Up @@ -91,7 +91,7 @@ public virtual void GetResponseAsync(Action<TResponse> 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(
Expand Down
10 changes: 9 additions & 1 deletion Source/Zencoder/Response.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,15 @@ public string[] Errors
/// </summary>
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); }
}

/// <summary>
/// Gets a value indicating whether the request was successful but returned no content.
/// </summary>
public virtual bool NoContent
{
get { return this.RequestException == null && this.StatusCode == HttpStatusCode.NoContent; }
}

/// <summary>
Expand Down
6 changes: 3 additions & 3 deletions Source/Zencoder/ResubmitJobRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public int JobId
/// </summary>
public override Uri Url
{
get
get
{
if (this.url == null)
{
Expand All @@ -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;
Expand All @@ -81,7 +81,7 @@ public override Uri Url
/// </summary>
public override string Verb
{
get { return "GET"; }
get { return "PUT"; }
}
}
}
55 changes: 54 additions & 1 deletion Source/Zencoder/Zencoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class Zencoder
/// <summary>
/// Gets the default API base URL.
/// </summary>
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");

/// <summary>
/// Initializes a new instance of the Zencoder class.
Expand Down Expand Up @@ -273,6 +273,32 @@ public CreateJobResponse CreateJob(string input, IEnumerable<Output> outputs, in
return request.WithOutputs(outputs).GetResponse();
}

/// <summary>
/// A blocking create job request/response cycle.
/// </summary>
/// <param name="input">The URL of the input file.</param>
/// <param name="outputs">The output definition collection.</param>
/// <param name="downloadConnections">The number of download connections to use when fetching the input file.</param>
/// <param name="region">The region to perform the job in.</param>
/// <param name="test">A value indicating whether to use test mode.</param>
/// <param name="mock">A value indicating whether to mock the response rather than actually creating a job.</param>
/// <param name="passThrough">A value that will be passed along and stored with the request.</param>
/// <returns>The call response.</returns>
public CreateJobResponse CreateJob(string input, IEnumerable<Output> 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();
}

/// <summary>
/// A blocking create job request/response cycle.
/// </summary>
Expand All @@ -297,6 +323,33 @@ public void CreateJob(string input, IEnumerable<Output> outputs, int? downloadCo
request.WithOutputs(outputs).GetResponseAsync(callback);
}

/// <summary>
/// A blocking create job request/response cycle.
/// </summary>
/// <param name="input">The URL of the input file.</param>
/// <param name="outputs">The output definition collection.</param>
/// <param name="downloadConnections">The number of download connections to use when fetching the input file.</param>
/// <param name="region">The region to perform the job in.</param>
/// <param name="test">A value indicating whether to use test mode.</param>
/// <param name="mock">A value indicating whether to mock the response rather than actually creating a job.</param>
/// <param name="passThrough">A value that will be passed along and stored with the request.</param>
/// <param name="callback">The call response.</param>
public void CreateJob(string input, IEnumerable<Output> outputs, int? downloadConnections, string region, bool? test, bool? mock, string passThrough, Action<CreateJobResponse> callback)
{
CreateJobRequest request = new CreateJobRequest(this)
{
DownloadConnections = downloadConnections,
Input = input,
Mock = mock,
Region = region,
Test = test,
PassThrough = passThrough
};

request.WithOutputs(outputs).GetResponseAsync(callback);
}


/// <summary>
/// A blocking delete job request/response cycle.
/// </summary>
Expand Down
3 changes: 2 additions & 1 deletion Source/Zencoder/Zencoder.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,9 @@
<Compile Include="H264Profile.cs" />
<Compile Include="HttpNotification.cs" />
<Compile Include="HttpPostNotification.cs" />
<Compile Include="HttpPostNotificationJob.cs" />
<Compile Include="HttpPostNotificationOutput.cs" />
<Compile Include="HttpPostNotificationJob.cs" />
<Compile Include="HttpPostNotificationInput.cs" />
<Compile Include="INotificationReceiver.cs" />
<Compile Include="InputMediaFile.cs" />
<Compile Include="InputState.cs" />
Expand Down