mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 13:11:10 +00:00
Adds seekable normalized audio track delivery
This commit is contained in:
1 parent
4e13b23f16
commit
45f9aa3bd5
57 files changed
+3452
-344
No files matched your search
@@ -1,5 +1,6 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Domain.SharedKernel.Common.Enums.AudioLibrary;
|
||||
using System;
|
||||
using System.Collections.Frozen;
|
||||
using System.Collections.Generic;
|
||||
#endregion
|
||||
@@ -29,6 +30,20 @@ public static class MusicMimeTypes
|
||||
{ AudioFileFormat.MATROSKA, "audio/x-matroska" }
|
||||
}.ToFrozenDictionary();
|
||||
|
||||
// Container names are mapped to the file format enumeration instead of to their own media type strings, so the media type table above stays the
|
||||
// single source of truth and a new format only needs one entry.
|
||||
private static readonly FrozenDictionary<string, AudioFileFormat> s_containerToAudioFileFormat = new Dictionary<string, AudioFileFormat>(StringComparer.OrdinalIgnoreCase)
|
||||
{
|
||||
{ "MP3", AudioFileFormat.MP3 },
|
||||
{ "FLAC", AudioFileFormat.FLAC },
|
||||
{ "MP4", AudioFileFormat.M4A },
|
||||
{ "M4A", AudioFileFormat.M4A },
|
||||
{ "AAC", AudioFileFormat.AAC },
|
||||
{ "OGG", AudioFileFormat.OGG },
|
||||
{ "OPUS", AudioFileFormat.OPUS },
|
||||
{ "WAV", AudioFileFormat.WAV }
|
||||
}.ToFrozenDictionary(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the MIME content type of <paramref name="format"/>.
|
||||
/// </summary>
|
||||
@@ -38,4 +53,16 @@ public static class MusicMimeTypes
|
||||
{
|
||||
return s_audioFileFormatToMimeType.TryGetValue(format, out string? mimeType) ? mimeType : "application/octet-stream";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the MIME content type of an audio container, as named by the delivery decision of a playback manifest.
|
||||
/// </summary>
|
||||
/// <param name="container">The canonical container of the delivered audio, for example MP4, AAC, OGG, MP3, FLAC or WAV.</param>
|
||||
/// <returns>The MIME content type of <paramref name="container"/>, or <c>application/octet-stream</c> when the container is unknown.</returns>
|
||||
public static string GetContainerMimeType(string? container)
|
||||
{
|
||||
return !string.IsNullOrWhiteSpace(container) && s_containerToAudioFileFormat.TryGetValue(container.Trim(), out AudioFileFormat format)
|
||||
? GetMimeType(format)
|
||||
: "application/octet-stream";
|
||||
}
|
||||
}
|
||||
+1
@@ -15,6 +15,7 @@ public static partial class ApiRoutes
|
||||
public const string UPDATE_TRACK = "/libraries/{libraryId}/artists/{artistId}/albums/{albumId}/tracks/{trackId}";
|
||||
public const string DELETE_TRACK = "/libraries/{libraryId}/artists/{artistId}/albums/{albumId}/tracks/{trackId}";
|
||||
public const string STREAM_TRACK = "/libraries/{libraryId}/artists/{artistId}/albums/{albumId}/tracks/{trackId}/stream";
|
||||
public const string STREAM_TRACK_SEGMENT = "/libraries/{libraryId}/artists/{artistId}/albums/{albumId}/tracks/{trackId}/stream/deliveries/{deliveryId}/segments/{segmentIndex}";
|
||||
public const string GET_PLAYBACK_MANIFEST = "/libraries/{libraryId}/artists/{artistId}/albums/{albumId}/tracks/{trackId}/playback-manifest";
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user