| | | 1 | | using System; |
| | | 2 | | using System.IO; |
| | | 3 | | using MediaBrowser.Model.Configuration; |
| | | 4 | | |
| | | 5 | | namespace MediaBrowser.Common.Configuration |
| | | 6 | | { |
| | | 7 | | /// <summary> |
| | | 8 | | /// Class containing extension methods for working with the encoding configuration. |
| | | 9 | | /// </summary> |
| | | 10 | | public static class EncodingConfigurationExtensions |
| | | 11 | | { |
| | | 12 | | /// <summary> |
| | | 13 | | /// Gets the encoding options. |
| | | 14 | | /// </summary> |
| | | 15 | | /// <param name="configurationManager">The configuration manager.</param> |
| | | 16 | | /// <returns>The encoding options.</returns> |
| | | 17 | | public static EncodingOptions GetEncodingOptions(this IConfigurationManager configurationManager) |
| | 4 | 18 | | => configurationManager.GetConfiguration<EncodingOptions>("encoding"); |
| | | 19 | | |
| | | 20 | | /// <summary> |
| | | 21 | | /// Retrieves the transcoding temp path from the encoding configuration, falling back to a default if no path |
| | | 22 | | /// is specified in configuration. If the directory does not exist, it will be created. |
| | | 23 | | /// </summary> |
| | | 24 | | /// <param name="configurationManager">The configuration manager.</param> |
| | | 25 | | /// <returns>The transcoding temp path.</returns> |
| | | 26 | | /// <exception cref="UnauthorizedAccessException">If the directory does not exist, and the caller does not have |
| | | 27 | | /// <exception cref="NotSupportedException">If there is a custom path transcoding path specified, but it is inva |
| | | 28 | | /// <exception cref="IOException">If the directory does not exist, and it also could not be created.</exception> |
| | | 29 | | public static string GetTranscodePath(this IConfigurationManager configurationManager) |
| | | 30 | | { |
| | | 31 | | // Get the configured path and fall back to a default |
| | 4 | 32 | | var transcodingTempPath = configurationManager.GetEncodingOptions().TranscodingTempPath; |
| | 4 | 33 | | if (string.IsNullOrEmpty(transcodingTempPath)) |
| | | 34 | | { |
| | 4 | 35 | | transcodingTempPath = Path.Combine(configurationManager.CommonApplicationPaths.CachePath, "transcodes"); |
| | | 36 | | } |
| | | 37 | | |
| | 4 | 38 | | configurationManager.CommonApplicationPaths.CreateAndCheckMarker(transcodingTempPath, "transcode", true); |
| | 4 | 39 | | return transcodingTempPath; |
| | | 40 | | } |
| | | 41 | | } |
| | | 42 | | } |