return Mixdowns.SingleOrDefault(m => m.ShortName == shortName);\r
}\r
\r
+ /// <summary>\r
+ /// Gets the mixdown with the specified ID.\r
+ /// </summary>\r
+ /// <param name="id">The mixdown ID.</param>\r
+ /// <returns>The requested mixdown.</returns>\r
+ public static HBMixdown GetMixdown(int id)\r
+ {\r
+ return Mixdowns.SingleOrDefault(m => m.Id == id);\r
+ }\r
+\r
/// <summary>\r
/// Gets the container with the specified short name.\r
/// </summary>\r
return Mixdowns.Single(m => m.Id == defaultMixdown);\r
}\r
\r
+ /// <summary>\r
+ /// Sanitizes the given sample rate for the given encoder.\r
+ /// </summary>\r
+ /// <param name="encoder">The encoder.</param>\r
+ /// <param name="sampleRate">The sample rate to sanitize.</param>\r
+ /// <returns>The sanitized sample rate.</returns>\r
+ public static int SanitizeSampleRate(HBAudioEncoder encoder, int sampleRate)\r
+ {\r
+ return HBFunctions.hb_audio_samplerate_find_closest(sampleRate, (uint)encoder.Id);\r
+ }\r
+\r
/// <summary>\r
/// Gets the bitrate limits for the given audio codec, sample rate and mixdown.\r
/// </summary>\r
/// </summary>\r
private JsonScanObject titles;\r
\r
+ /// <summary>\r
+ /// The raw JSON for the titles list.\r
+ /// </summary>\r
+ private string titlesJson;\r
+\r
/// <summary>\r
/// The index of the default title.\r
/// </summary>\r
}\r
}\r
\r
+ /// <summary>\r
+ /// Gets the raw JSON for the list of titles on this instance.\r
+ /// </summary>\r
+ public string TitlesJson\r
+ {\r
+ get\r
+ {\r
+ return this.titlesJson;\r
+ }\r
+ }\r
+\r
/// <summary>\r
/// Gets the index of the default title.\r
/// </summary>\r
};\r
\r
string encode = JsonConvert.SerializeObject(encodeObject, Formatting.Indented, settings);\r
- HBFunctions.hb_add_json(this.hbHandle, InteropUtilities.ToUtf8PtrFromString(encode));\r
+ this.StartEncode(encode);\r
+ }\r
+\r
+ /// <summary>\r
+ /// Starts an encode with the given job JSON.\r
+ /// </summary>\r
+ /// <param name="encodeJson">The JSON for the job to start.</param>\r
+ [HandleProcessCorruptedStateExceptions]\r
+ public void StartEncode(string encodeJson)\r
+ {\r
+ HBFunctions.hb_add_json(this.hbHandle, InteropUtilities.ToUtf8PtrFromString(encodeJson));\r
HBFunctions.hb_start(this.hbHandle);\r
\r
this.encodePollTimer = new Timer();\r
this.scanPollTimer.Stop();\r
\r
var jsonMsg = HBFunctions.hb_get_title_set_json(this.hbHandle);\r
- string scanJson = InteropUtilities.ToStringFromUtf8Ptr(jsonMsg);\r
- this.log.LogMessage(scanJson, LogMessageType.Progress, LogLevel.Trace);\r
+ this.titlesJson = InteropUtilities.ToStringFromUtf8Ptr(jsonMsg);\r
+ this.log.LogMessage(this.titlesJson, LogMessageType.Progress, LogLevel.Trace);\r
\r
if (string.IsNullOrEmpty(scanJson))\r
{\r
}\r
else\r
{\r
- this.titles = JsonConvert.DeserializeObject<JsonScanObject>(scanJson);\r
+ this.titles = JsonConvert.DeserializeObject<JsonScanObject>(this.titlesJson);\r
if (this.titles != null)\r
{\r
this.featureTitle = this.titles.MainFeature;\r
[DllImport("hb", EntryPoint = "hb_audio_samplerate_get_next", CallingConvention = CallingConvention.Cdecl)]\r
public static extern IntPtr hb_audio_samplerate_get_next(IntPtr last);\r
\r
+ [DllImport("hb", EntryPoint = "hb_audio_samplerate_find_closest", CallingConvention = CallingConvention.Cdecl)]\r
+ public static extern int hb_audio_samplerate_find_closest(int samplerate, uint codec);\r
\r
[DllImport("hb", EntryPoint = "hb_audio_bitrate_get_best", CallingConvention = CallingConvention.Cdecl)]\r
public static extern int hb_audio_bitrate_get_best(uint codec, int bitrate, int samplerate, int mixdown);\r