Skip to content

Commit

Permalink
Merge pull request #7 from hudl/ELITE-883-UpdateZencoder
Browse files Browse the repository at this point in the history
ELITE-883 Update zencoder
  • Loading branch information
robbhudl authored Sep 1, 2022
2 parents 44fef20 + 1a39e51 commit cb38697
Show file tree
Hide file tree
Showing 90 changed files with 6,950 additions and 15 deletions.
53 changes: 53 additions & 0 deletions Source/Hudl.Zencoder/AccountDetailsRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
//-----------------------------------------------------------------------
// <copyright file="AccountDetailsRequest.cs" company="Tasty Codes">
// Copyright (c) 2010 Chad Burggraf.
// </copyright>
//-----------------------------------------------------------------------

namespace Zencoder
{
using System;
using Newtonsoft.Json;

/// <summary>
/// Implements the account details request.
/// </summary>
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
public class AccountDetailsRequest : Request<AccountDetailsRequest, AccountDetailsResponse>
{
/// <summary>
/// Initializes a new instance of the AccountDetailsRequest class.
/// </summary>
/// <param name="zencoder">The <see cref="ZencoderServices"/> service to create the request with.</param>
public AccountDetailsRequest(ZencoderServices zencoder)
: base(zencoder)
{
}

/// <summary>
/// Initializes a new instance of the AccountDetailsRequest class.
/// </summary>
/// <param name="apiKey">The API key to use when connecting to the service.</param>
/// <param name="baseUrl">The service base URL.</param>
public AccountDetailsRequest(string apiKey, Uri baseUrl)
: base(apiKey, baseUrl)
{
}

/// <summary>
/// Gets the concrete URL this request will call.
/// </summary>
public override Uri Url
{
get { return BaseUrl.AppendPath("account").WithApiKey(ApiKey); }
}

/// <summary>
/// Gets the HTTP verb to use when making the request.
/// </summary>
public override string Verb
{
get { return "GET"; }
}
}
}
57 changes: 57 additions & 0 deletions Source/Hudl.Zencoder/AccountDetailsResponse.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
//-----------------------------------------------------------------------
// <copyright file="AccountDetailsResponse.cs" company="Tasty Codes">
// Copyright (c) 2010 Chad Burggraf.
// </copyright>
//-----------------------------------------------------------------------

namespace Zencoder
{
using System;
using Newtonsoft.Json;

/// <summary>
/// Implements the account details response.
/// </summary>
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
public class AccountDetailsResponse : Response<AccountDetailsRequest, AccountDetailsResponse>
{
/// <summary>
/// Gets or sets the account's current state.
/// Sorry about the string, kids. Could't find an exhaustive list of states.
/// </summary>
[JsonProperty("account_state")]
public string AccountState { get; set; }

/// <summary>
/// Gets or sets the account's current billing state.
/// Sorry about the string, kids. Could't find an exhaustive list of states.
/// </summary>
[JsonProperty("billing_state")]
public string BillingState { get; set; }

/// <summary>
/// Gets or sets a value indicating whether the account is in integration mode.
/// </summary>
[JsonProperty("integration_mode")]
[JsonConverter(typeof(BooleanConverter))]
public bool IntegrationMode { get; set; }

/// <summary>
/// Gets or sets the number of minutes included in the account's plan.
/// </summary>
[JsonProperty("minutes_included")]
public int MinutesIncluded { get; set; }

/// <summary>
/// Gets or sets the number of minutes used by the account.
/// </summary>
[JsonProperty("minutes_used")]
public int MinutesUsed { get; set; }

/// <summary>
/// Gets or sets the account's plan.
/// </summary>
[JsonProperty("plan")]
public string Plan { get; set; }
}
}
74 changes: 74 additions & 0 deletions Source/Hudl.Zencoder/AccountIntegrationModeRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
//-----------------------------------------------------------------------
// <copyright file="AccountIntegrationModeRequest.cs" company="Tasty Codes">
// Copyright (c) 2010 Chad Burggraf.
// </copyright>
//-----------------------------------------------------------------------

namespace Zencoder
{
using System;
using System.IO;
using Newtonsoft.Json;

/// <summary>
/// Implements the account integration mode request.
/// </summary>
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
public class AccountIntegrationModeRequest : Request<AccountIntegrationModeRequest, AccountIntegrationModeResponse>
{
/// <summary>
/// Initializes a new instance of the AccountIntegrationModeRequest class.
/// </summary>
/// <param name="zencoder">The <see cref="ZencoderServices"/> service to create the request with.</param>
public AccountIntegrationModeRequest(ZencoderServices zencoder)
: base(zencoder)
{
}

/// <summary>
/// Initializes a new instance of the AccountIntegrationModeRequest class.
/// </summary>
/// <param name="apiKey">The API key to use when connecting to the service.</param>
/// <param name="baseUrl">The service base URL.</param>
public AccountIntegrationModeRequest(string apiKey, Uri baseUrl)
: base(apiKey, baseUrl)
{
}

/// <summary>
/// Gets or sets a value indicating whether to enable integration mode for the account.
/// </summary>
public bool Enable { get; set; }

/// <summary>
/// Gets the concrete URL this request will call.
/// </summary>
public override Uri Url
{
get
{
return (this.Enable ?
BaseUrl.AppendPath("account/integration") :
BaseUrl.AppendPath("account/live")).WithApiKey(ApiKey);
}
}

/// <summary>
/// Gets the HTTP verb to use when making the request.
/// </summary>
public override string Verb
{
get { return "GET"; }
}

/// <summary>
/// Reads any data from the response stream into a new <see cref="Response"/> instance.
/// </summary>
/// <param name="stream">The stream to read from.</param>
/// <returns>The created response.</returns>
protected override AccountIntegrationModeResponse ReadResponse(Stream stream)
{
return new AccountIntegrationModeResponse();
}
}
}
19 changes: 19 additions & 0 deletions Source/Hudl.Zencoder/AccountIntegrationModeResponse.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//-----------------------------------------------------------------------
// <copyright file="AccountIntegrationModeResponse.cs" company="Tasty Codes">
// Copyright (c) 2010 Chad Burggraf.
// </copyright>
//-----------------------------------------------------------------------

namespace Zencoder
{
using System;
using Newtonsoft.Json;

/// <summary>
/// Implements the account integration mode response.
/// </summary>
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
public class AccountIntegrationModeResponse : Response<AccountDetailsRequest, AccountIntegrationModeResponse>
{
}
}
39 changes: 39 additions & 0 deletions Source/Hudl.Zencoder/AspectMode.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//-----------------------------------------------------------------------
// <copyright file="AspectMode.cs" company="Tasty Codes">
// Copyright (c) 2010 Chad Burggraf.
// </copyright>
//-----------------------------------------------------------------------

namespace Zencoder
{
using System;
using Newtonsoft.Json;

/// <summary>
/// Defines the possible output video aspect modes.
/// </summary>
[JsonConverter(typeof(EnumLowercaseJsonConverter))]
public enum AspectMode
{
/// <summary>
/// Identifies that the input aspect ratio is preserved.
/// </summary>
Preserve = 0,

/// <summary>
/// Identifies that the output will be stretched to fit the specified size, even if distortion occurs.
/// </summary>
Stretch,

/// <summary>
/// Identifies that the output will be cropped to fit the specified size.
/// Equivalent to "pan and scan".
/// </summary>
Crop,

/// <summary>
/// Identifies that the output will be letterboxed to match the specified size exactly.
/// </summary>
Pad
}
}
43 changes: 43 additions & 0 deletions Source/Hudl.Zencoder/AudioCodec.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
//-----------------------------------------------------------------------
// <copyright file="AudioCodec.cs" company="Tasty Codes">
// Copyright (c) 2010 Chad Burggraf.
// </copyright>
//-----------------------------------------------------------------------

namespace Zencoder
{
using System;
using Newtonsoft.Json;

/// <summary>
/// Defines the possible output audio codecs.
/// </summary>
[JsonConverter(typeof(EnumLowercaseJsonConverter))]
public enum AudioCodec
{
/// <summary>
/// Identifies the AAC audio codec.
/// </summary>
Aac = 0,

/// <summary>
/// Identifies the AMR audio codec.
/// </summary>
Amr,

/// <summary>
/// Identifies that MP3 audio codec.
/// </summary>
Mp3,

/// <summary>
/// Identifies the Vorbis audio codec.
/// </summary>
Vorbis,

/// <summary>
/// Identifies the WMA audio codec.
/// </summary>
Wma
}
}
81 changes: 81 additions & 0 deletions Source/Hudl.Zencoder/BooleanConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
//-----------------------------------------------------------------------
// <copyright file="BooleanConverter.cs" company="Tasty Codes">
// Copyright (c) 2010 Chad Burggraf.
// </copyright>
//-----------------------------------------------------------------------

namespace Zencoder
{
using System;
using System.Globalization;
using System.Text.RegularExpressions;
using Newtonsoft.Json;

/// <summary>
/// Provides custom JSON serialization to allow any combination of "true", "false", "1" or "0" to be used for booleans.
/// </summary>
public class BooleanConverter : JsonConverter
{
private static readonly Regex allDigitsExp = new Regex(@"^[-+]?[0-9]*\.?[0-9]+$", RegexOptions.Compiled);

/// <summary>
/// Determines whether this instance can convert the specified object type.
/// </summary>
/// <param name="objectType">Type of the object.</param>
/// <returns>True if this instance can convert the specified object type, otherwise false.</returns>
public override bool CanConvert(Type objectType)
{
return typeof(bool?).IsAssignableFrom(objectType);
}

/// <summary>
/// Reads the JSON representation of the object.
/// </summary>
/// <param name="reader">The JsonReader to read from.</param>
/// <param name="objectType">Type of the object.</param>
/// <param name="existingValue">The existing value of the object being read.</param>
/// <param name="serializer">The calling serializer.</param>
/// <returns>The object value.</returns>
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
string str = (reader.Value ?? string.Empty).ToString().Trim();
object result = existingValue;

if (!string.IsNullOrEmpty(str))
{
try
{
if (allDigitsExp.IsMatch(str))
{
int number = (int)Convert.ToSingle(str, CultureInfo.InvariantCulture);
result = number == 0 ? false : true;
}
else
{
result = Convert.ToBoolean(str, CultureInfo.InvariantCulture);
}
}
catch (FormatException)
{
}
catch (OverflowException)
{
}
}

return result;
}

/// <summary>
/// Writes the JSON representation of the object.
/// </summary>
/// <param name="writer">The JsonWriter to write to.</param>
/// <param name="value">The value.</param>
/// <param name="serializer">The calling serializer.</param>
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
bool? b = (bool?)value;
serializer.Serialize(writer, !b.HasValue || !b.Value ? "0" : "1");
}
}
}
Loading

0 comments on commit cb38697

Please sign in to comment.