2020-11-21 13:26:03 +00:00
|
|
|
using System;
|
2020-08-01 12:38:55 +00:00
|
|
|
using System.Collections.Generic;
|
2020-09-05 23:11:44 +00:00
|
|
|
using System.ComponentModel.DataAnnotations;
|
2020-08-01 12:38:55 +00:00
|
|
|
using System.Globalization;
|
|
|
|
using System.Linq;
|
|
|
|
using System.Threading.Tasks;
|
2020-09-01 23:26:49 +00:00
|
|
|
using Jellyfin.Api.Attributes;
|
2020-08-01 13:09:44 +00:00
|
|
|
using Jellyfin.Api.Constants;
|
2020-08-01 12:38:55 +00:00
|
|
|
using Jellyfin.Api.Helpers;
|
2020-11-17 03:29:46 +00:00
|
|
|
using Jellyfin.Api.ModelBinders;
|
2020-08-09 23:20:14 +00:00
|
|
|
using Jellyfin.Api.Models.StreamingDtos;
|
2020-09-10 12:16:41 +00:00
|
|
|
using MediaBrowser.Common.Extensions;
|
2020-08-09 23:20:14 +00:00
|
|
|
using MediaBrowser.Controller.Devices;
|
|
|
|
using MediaBrowser.Controller.Library;
|
|
|
|
using MediaBrowser.Controller.MediaEncoding;
|
2020-08-01 12:38:55 +00:00
|
|
|
using MediaBrowser.Controller.Net;
|
|
|
|
using MediaBrowser.Model.Dlna;
|
|
|
|
using MediaBrowser.Model.MediaInfo;
|
2022-01-23 16:37:52 +00:00
|
|
|
using MediaBrowser.Model.Session;
|
2020-08-01 13:09:44 +00:00
|
|
|
using Microsoft.AspNetCore.Authorization;
|
|
|
|
using Microsoft.AspNetCore.Http;
|
2020-08-01 12:38:55 +00:00
|
|
|
using Microsoft.AspNetCore.Mvc;
|
2020-08-09 23:20:14 +00:00
|
|
|
using Microsoft.Extensions.Logging;
|
2020-08-01 12:38:55 +00:00
|
|
|
|
|
|
|
namespace Jellyfin.Api.Controllers
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// The universal audio controller.
|
|
|
|
/// </summary>
|
2020-08-04 18:48:53 +00:00
|
|
|
[Route("")]
|
2020-08-01 12:38:55 +00:00
|
|
|
public class UniversalAudioController : BaseJellyfinApiController
|
|
|
|
{
|
|
|
|
private readonly IAuthorizationContext _authorizationContext;
|
2020-08-09 23:20:14 +00:00
|
|
|
private readonly IDeviceManager _deviceManager;
|
|
|
|
private readonly ILibraryManager _libraryManager;
|
|
|
|
private readonly ILogger<UniversalAudioController> _logger;
|
|
|
|
private readonly MediaInfoHelper _mediaInfoHelper;
|
|
|
|
private readonly AudioHelper _audioHelper;
|
|
|
|
private readonly DynamicHlsHelper _dynamicHlsHelper;
|
2020-08-01 12:38:55 +00:00
|
|
|
|
2020-08-01 13:09:44 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Initializes a new instance of the <see cref="UniversalAudioController"/> class.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="authorizationContext">Instance of the <see cref="IAuthorizationContext"/> interface.</param>
|
2020-08-09 23:20:14 +00:00
|
|
|
/// <param name="deviceManager">Instance of the <see cref="IDeviceManager"/> interface.</param>
|
|
|
|
/// <param name="libraryManager">Instance of the <see cref="ILibraryManager"/> interface.</param>
|
|
|
|
/// <param name="logger">Instance of the <see cref="ILogger{UniversalAudioController}"/> interface.</param>
|
|
|
|
/// <param name="mediaInfoHelper">Instance of <see cref="MediaInfoHelper"/>.</param>
|
|
|
|
/// <param name="audioHelper">Instance of <see cref="AudioHelper"/>.</param>
|
|
|
|
/// <param name="dynamicHlsHelper">Instance of <see cref="DynamicHlsHelper"/>.</param>
|
2020-08-01 12:38:55 +00:00
|
|
|
public UniversalAudioController(
|
|
|
|
IAuthorizationContext authorizationContext,
|
2020-08-09 23:20:14 +00:00
|
|
|
IDeviceManager deviceManager,
|
|
|
|
ILibraryManager libraryManager,
|
|
|
|
ILogger<UniversalAudioController> logger,
|
|
|
|
MediaInfoHelper mediaInfoHelper,
|
|
|
|
AudioHelper audioHelper,
|
|
|
|
DynamicHlsHelper dynamicHlsHelper)
|
2020-08-01 12:38:55 +00:00
|
|
|
{
|
|
|
|
_authorizationContext = authorizationContext;
|
2020-08-09 23:20:14 +00:00
|
|
|
_deviceManager = deviceManager;
|
|
|
|
_libraryManager = libraryManager;
|
|
|
|
_logger = logger;
|
|
|
|
_mediaInfoHelper = mediaInfoHelper;
|
|
|
|
_audioHelper = audioHelper;
|
|
|
|
_dynamicHlsHelper = dynamicHlsHelper;
|
2020-08-01 12:38:55 +00:00
|
|
|
}
|
|
|
|
|
2020-08-01 13:09:44 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Gets an audio stream.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="itemId">The item id.</param>
|
|
|
|
/// <param name="container">Optional. The audio container.</param>
|
|
|
|
/// <param name="mediaSourceId">The media version id, if playing an alternate version.</param>
|
|
|
|
/// <param name="deviceId">The device id of the client requesting. Used to stop encoding processes when needed.</param>
|
|
|
|
/// <param name="userId">Optional. The user id.</param>
|
|
|
|
/// <param name="audioCodec">Optional. The audio codec to transcode to.</param>
|
|
|
|
/// <param name="maxAudioChannels">Optional. The maximum number of audio channels.</param>
|
|
|
|
/// <param name="transcodingAudioChannels">Optional. The number of how many audio channels to transcode to.</param>
|
|
|
|
/// <param name="maxStreamingBitrate">Optional. The maximum streaming bitrate.</param>
|
2020-10-31 08:09:22 +00:00
|
|
|
/// <param name="audioBitRate">Optional. Specify an audio bitrate to encode to, e.g. 128000. If omitted this will be left to encoder defaults.</param>
|
2020-08-01 13:09:44 +00:00
|
|
|
/// <param name="startTimeTicks">Optional. Specify a starting offset, in ticks. 1 tick = 10000 ms.</param>
|
|
|
|
/// <param name="transcodingContainer">Optional. The container to transcode to.</param>
|
|
|
|
/// <param name="transcodingProtocol">Optional. The transcoding protocol.</param>
|
|
|
|
/// <param name="maxAudioSampleRate">Optional. The maximum audio sample rate.</param>
|
|
|
|
/// <param name="maxAudioBitDepth">Optional. The maximum audio bit depth.</param>
|
|
|
|
/// <param name="enableRemoteMedia">Optional. Whether to enable remote media.</param>
|
|
|
|
/// <param name="breakOnNonKeyFrames">Optional. Whether to break on non key frames.</param>
|
|
|
|
/// <param name="enableRedirection">Whether to enable redirection. Defaults to true.</param>
|
|
|
|
/// <response code="200">Audio stream returned.</response>
|
|
|
|
/// <response code="302">Redirected to remote audio stream.</response>
|
|
|
|
/// <returns>A <see cref="Task"/> containing the audio file.</returns>
|
2020-08-04 18:48:53 +00:00
|
|
|
[HttpGet("Audio/{itemId}/universal")]
|
|
|
|
[HttpHead("Audio/{itemId}/universal", Name = "HeadUniversalAudioStream")]
|
2020-08-01 13:09:44 +00:00
|
|
|
[Authorize(Policy = Policies.DefaultAuthorization)]
|
|
|
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
|
|
|
[ProducesResponseType(StatusCodes.Status302Found)]
|
2020-09-01 23:26:49 +00:00
|
|
|
[ProducesAudioFile]
|
2020-08-01 12:38:55 +00:00
|
|
|
public async Task<ActionResult> GetUniversalAudioStream(
|
2020-09-06 15:07:27 +00:00
|
|
|
[FromRoute, Required] Guid itemId,
|
2020-11-17 03:29:46 +00:00
|
|
|
[FromQuery, ModelBinder(typeof(CommaDelimitedArrayModelBinder))] string[] container,
|
2020-08-01 12:38:55 +00:00
|
|
|
[FromQuery] string? mediaSourceId,
|
|
|
|
[FromQuery] string? deviceId,
|
|
|
|
[FromQuery] Guid? userId,
|
|
|
|
[FromQuery] string? audioCodec,
|
|
|
|
[FromQuery] int? maxAudioChannels,
|
|
|
|
[FromQuery] int? transcodingAudioChannels,
|
2020-10-31 08:09:22 +00:00
|
|
|
[FromQuery] int? maxStreamingBitrate,
|
|
|
|
[FromQuery] int? audioBitRate,
|
2020-08-01 12:38:55 +00:00
|
|
|
[FromQuery] long? startTimeTicks,
|
|
|
|
[FromQuery] string? transcodingContainer,
|
|
|
|
[FromQuery] string? transcodingProtocol,
|
|
|
|
[FromQuery] int? maxAudioSampleRate,
|
|
|
|
[FromQuery] int? maxAudioBitDepth,
|
|
|
|
[FromQuery] bool? enableRemoteMedia,
|
2021-03-05 01:25:52 +00:00
|
|
|
[FromQuery] bool breakOnNonKeyFrames = false,
|
2020-08-01 12:38:55 +00:00
|
|
|
[FromQuery] bool enableRedirection = true)
|
|
|
|
{
|
|
|
|
var deviceProfile = GetDeviceProfile(container, transcodingContainer, audioCodec, transcodingProtocol, breakOnNonKeyFrames, transcodingAudioChannels, maxAudioSampleRate, maxAudioBitDepth, maxAudioChannels);
|
2021-05-21 03:56:59 +00:00
|
|
|
(await _authorizationContext.GetAuthorizationInfo(Request).ConfigureAwait(false)).DeviceId = deviceId;
|
2020-08-01 12:38:55 +00:00
|
|
|
|
2021-05-21 03:56:59 +00:00
|
|
|
var authInfo = await _authorizationContext.GetAuthorizationInfo(Request).ConfigureAwait(false);
|
2020-08-09 23:20:14 +00:00
|
|
|
|
|
|
|
_logger.LogInformation("GetPostedPlaybackInfo profile: {@Profile}", deviceProfile);
|
|
|
|
|
|
|
|
if (deviceProfile == null)
|
|
|
|
{
|
2020-08-18 13:29:39 +00:00
|
|
|
var clientCapabilities = _deviceManager.GetCapabilities(authInfo.DeviceId);
|
|
|
|
if (clientCapabilities != null)
|
2020-08-09 23:20:14 +00:00
|
|
|
{
|
2020-08-18 13:29:39 +00:00
|
|
|
deviceProfile = clientCapabilities.DeviceProfile;
|
2020-08-09 23:20:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var info = await _mediaInfoHelper.GetPlaybackInfo(
|
|
|
|
itemId,
|
|
|
|
userId,
|
|
|
|
mediaSourceId)
|
2020-08-01 17:03:11 +00:00
|
|
|
.ConfigureAwait(false);
|
2020-08-01 12:38:55 +00:00
|
|
|
|
2020-08-09 23:20:14 +00:00
|
|
|
if (deviceProfile != null)
|
|
|
|
{
|
|
|
|
// set device specific data
|
|
|
|
var item = _libraryManager.GetItemById(itemId);
|
|
|
|
|
|
|
|
foreach (var sourceInfo in info.MediaSources)
|
|
|
|
{
|
|
|
|
_mediaInfoHelper.SetDeviceSpecificData(
|
|
|
|
item,
|
|
|
|
sourceInfo,
|
|
|
|
deviceProfile,
|
|
|
|
authInfo,
|
|
|
|
maxStreamingBitrate ?? deviceProfile.MaxStreamingBitrate,
|
|
|
|
startTimeTicks ?? 0,
|
|
|
|
mediaSourceId ?? string.Empty,
|
|
|
|
null,
|
|
|
|
null,
|
|
|
|
maxAudioChannels,
|
2021-10-03 03:43:05 +00:00
|
|
|
info.PlaySessionId!,
|
2020-08-09 23:20:14 +00:00
|
|
|
userId ?? Guid.Empty,
|
|
|
|
true,
|
|
|
|
true,
|
|
|
|
true,
|
|
|
|
true,
|
|
|
|
true,
|
2020-09-10 12:16:41 +00:00
|
|
|
Request.HttpContext.GetNormalizedRemoteIp());
|
2020-08-09 23:20:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
_mediaInfoHelper.SortMediaSources(info, maxStreamingBitrate);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (info.MediaSources != null)
|
|
|
|
{
|
|
|
|
foreach (var source in info.MediaSources)
|
|
|
|
{
|
|
|
|
_mediaInfoHelper.NormalizeMediaSourceContainer(source, deviceProfile!, DlnaProfileType.Video);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var mediaSource = info.MediaSources![0];
|
2020-08-01 12:38:55 +00:00
|
|
|
if (mediaSource.SupportsDirectPlay && mediaSource.Protocol == MediaProtocol.Http)
|
|
|
|
{
|
|
|
|
if (enableRedirection)
|
|
|
|
{
|
|
|
|
if (mediaSource.IsRemote && enableRemoteMedia.HasValue && enableRemoteMedia.Value)
|
|
|
|
{
|
|
|
|
return Redirect(mediaSource.Path);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var isStatic = mediaSource.SupportsDirectStream;
|
|
|
|
if (!isStatic && string.Equals(mediaSource.TranscodingSubProtocol, "hls", StringComparison.OrdinalIgnoreCase))
|
|
|
|
{
|
|
|
|
// hls segment container can only be mpegts or fmp4 per ffmpeg documentation
|
2020-11-07 17:39:32 +00:00
|
|
|
// ffmpeg option -> file extension
|
|
|
|
// mpegts -> ts
|
|
|
|
// fmp4 -> mp4
|
2020-08-01 12:38:55 +00:00
|
|
|
// TODO: remove this when we switch back to the segment muxer
|
2020-11-07 17:39:32 +00:00
|
|
|
var supportedHlsContainers = new[] { "ts", "mp4" };
|
2020-08-01 12:38:55 +00:00
|
|
|
|
2020-08-09 23:20:14 +00:00
|
|
|
var dynamicHlsRequestDto = new HlsAudioRequestDto
|
2020-08-01 12:38:55 +00:00
|
|
|
{
|
2020-08-09 23:20:14 +00:00
|
|
|
Id = itemId,
|
|
|
|
Container = ".m3u8",
|
|
|
|
Static = isStatic,
|
|
|
|
PlaySessionId = info.PlaySessionId,
|
2020-08-01 13:09:44 +00:00
|
|
|
// fallback to mpegts if device reports some weird value unsupported by hls
|
2020-11-07 17:39:32 +00:00
|
|
|
SegmentContainer = Array.Exists(supportedHlsContainers, element => element == transcodingContainer) ? transcodingContainer : "ts",
|
2020-08-09 23:20:14 +00:00
|
|
|
MediaSourceId = mediaSourceId,
|
|
|
|
DeviceId = deviceId,
|
|
|
|
AudioCodec = audioCodec,
|
|
|
|
EnableAutoStreamCopy = true,
|
|
|
|
AllowAudioStreamCopy = true,
|
|
|
|
AllowVideoStreamCopy = true,
|
|
|
|
BreakOnNonKeyFrames = breakOnNonKeyFrames,
|
|
|
|
AudioSampleRate = maxAudioSampleRate,
|
|
|
|
MaxAudioChannels = maxAudioChannels,
|
|
|
|
MaxAudioBitDepth = maxAudioBitDepth,
|
2020-10-31 08:09:22 +00:00
|
|
|
AudioBitRate = audioBitRate ?? maxStreamingBitrate,
|
2020-08-09 23:20:14 +00:00
|
|
|
StartTimeTicks = startTimeTicks,
|
|
|
|
SubtitleMethod = SubtitleDeliveryMethod.Hls,
|
2021-03-22 19:53:55 +00:00
|
|
|
RequireAvc = false,
|
|
|
|
DeInterlace = false,
|
|
|
|
RequireNonAnamorphic = false,
|
|
|
|
EnableMpegtsM2TsMode = false,
|
2022-03-05 20:58:21 +00:00
|
|
|
TranscodeReasons = mediaSource.TranscodeReasons == 0 ? null : mediaSource.TranscodeReasons.ToString(),
|
2020-08-09 23:20:14 +00:00
|
|
|
Context = EncodingContext.Static,
|
|
|
|
StreamOptions = new Dictionary<string, string>(),
|
|
|
|
EnableAdaptiveBitrateStreaming = true
|
|
|
|
};
|
|
|
|
|
2020-08-10 13:53:32 +00:00
|
|
|
return await _dynamicHlsHelper.GetMasterHlsPlaylist(TranscodingJobType.Hls, dynamicHlsRequestDto, true)
|
2020-08-01 13:09:44 +00:00
|
|
|
.ConfigureAwait(false);
|
2020-08-01 12:38:55 +00:00
|
|
|
}
|
2020-08-09 23:20:14 +00:00
|
|
|
|
|
|
|
var audioStreamingDto = new StreamingRequestDto
|
2020-08-01 12:38:55 +00:00
|
|
|
{
|
2020-08-09 23:20:14 +00:00
|
|
|
Id = itemId,
|
|
|
|
Container = isStatic ? null : ("." + mediaSource.TranscodingContainer),
|
|
|
|
Static = isStatic,
|
|
|
|
PlaySessionId = info.PlaySessionId,
|
|
|
|
MediaSourceId = mediaSourceId,
|
|
|
|
DeviceId = deviceId,
|
|
|
|
AudioCodec = audioCodec,
|
|
|
|
EnableAutoStreamCopy = true,
|
|
|
|
AllowAudioStreamCopy = true,
|
|
|
|
AllowVideoStreamCopy = true,
|
|
|
|
BreakOnNonKeyFrames = breakOnNonKeyFrames,
|
|
|
|
AudioSampleRate = maxAudioSampleRate,
|
|
|
|
MaxAudioChannels = maxAudioChannels,
|
2020-10-31 08:09:22 +00:00
|
|
|
AudioBitRate = isStatic ? (int?)null : (audioBitRate ?? maxStreamingBitrate),
|
2020-08-09 23:20:14 +00:00
|
|
|
MaxAudioBitDepth = maxAudioBitDepth,
|
|
|
|
AudioChannels = maxAudioChannels,
|
|
|
|
CopyTimestamps = true,
|
|
|
|
StartTimeTicks = startTimeTicks,
|
|
|
|
SubtitleMethod = SubtitleDeliveryMethod.Embed,
|
2022-03-05 20:58:21 +00:00
|
|
|
TranscodeReasons = mediaSource.TranscodeReasons == 0 ? null : mediaSource.TranscodeReasons.ToString(),
|
2020-08-09 23:20:14 +00:00
|
|
|
Context = EncodingContext.Static
|
|
|
|
};
|
2020-08-01 12:38:55 +00:00
|
|
|
|
2020-08-10 13:53:32 +00:00
|
|
|
return await _audioHelper.GetAudioStream(TranscodingJobType.Progressive, audioStreamingDto).ConfigureAwait(false);
|
2020-08-01 12:38:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private DeviceProfile GetDeviceProfile(
|
2020-11-17 03:29:46 +00:00
|
|
|
string[] containers,
|
2020-08-01 12:38:55 +00:00
|
|
|
string? transcodingContainer,
|
|
|
|
string? audioCodec,
|
|
|
|
string? transcodingProtocol,
|
|
|
|
bool? breakOnNonKeyFrames,
|
|
|
|
int? transcodingAudioChannels,
|
|
|
|
int? maxAudioSampleRate,
|
|
|
|
int? maxAudioBitDepth,
|
|
|
|
int? maxAudioChannels)
|
|
|
|
{
|
|
|
|
var deviceProfile = new DeviceProfile();
|
|
|
|
|
2020-11-06 15:15:30 +00:00
|
|
|
int len = containers.Length;
|
|
|
|
var directPlayProfiles = new DirectPlayProfile[len];
|
|
|
|
for (int i = 0; i < len; i++)
|
2020-08-01 12:38:55 +00:00
|
|
|
{
|
2021-01-24 12:32:29 +00:00
|
|
|
var parts = containers[i].Split('|', StringSplitOptions.RemoveEmptyEntries);
|
2020-08-01 12:38:55 +00:00
|
|
|
|
2020-11-06 15:15:30 +00:00
|
|
|
var audioCodecs = parts.Length == 1 ? null : string.Join(',', parts.Skip(1));
|
2020-08-01 12:38:55 +00:00
|
|
|
|
2020-11-06 15:15:30 +00:00
|
|
|
directPlayProfiles[i] = new DirectPlayProfile
|
|
|
|
{
|
|
|
|
Type = DlnaProfileType.Audio,
|
|
|
|
Container = parts[0],
|
|
|
|
AudioCodec = audioCodecs
|
|
|
|
};
|
2020-08-01 12:38:55 +00:00
|
|
|
}
|
|
|
|
|
2020-11-06 15:15:30 +00:00
|
|
|
deviceProfile.DirectPlayProfiles = directPlayProfiles;
|
2020-08-01 12:38:55 +00:00
|
|
|
|
|
|
|
deviceProfile.TranscodingProfiles = new[]
|
|
|
|
{
|
|
|
|
new TranscodingProfile
|
|
|
|
{
|
|
|
|
Type = DlnaProfileType.Audio,
|
|
|
|
Context = EncodingContext.Streaming,
|
2021-05-01 11:06:10 +00:00
|
|
|
Container = transcodingContainer ?? "mp3",
|
|
|
|
AudioCodec = audioCodec ?? "mp3",
|
|
|
|
Protocol = transcodingProtocol ?? "http",
|
2020-08-01 12:38:55 +00:00
|
|
|
BreakOnNonKeyFrames = breakOnNonKeyFrames ?? false,
|
|
|
|
MaxAudioChannels = transcodingAudioChannels?.ToString(CultureInfo.InvariantCulture)
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
var codecProfiles = new List<CodecProfile>();
|
|
|
|
var conditions = new List<ProfileCondition>();
|
|
|
|
|
|
|
|
if (maxAudioSampleRate.HasValue)
|
|
|
|
{
|
|
|
|
// codec profile
|
2021-01-24 12:32:29 +00:00
|
|
|
conditions.Add(
|
|
|
|
new ProfileCondition
|
|
|
|
{
|
|
|
|
Condition = ProfileConditionType.LessThanEqual,
|
|
|
|
IsRequired = false,
|
|
|
|
Property = ProfileConditionValue.AudioSampleRate,
|
|
|
|
Value = maxAudioSampleRate.Value.ToString(CultureInfo.InvariantCulture)
|
|
|
|
});
|
2020-08-01 12:38:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (maxAudioBitDepth.HasValue)
|
|
|
|
{
|
|
|
|
// codec profile
|
2021-01-24 12:32:29 +00:00
|
|
|
conditions.Add(
|
|
|
|
new ProfileCondition
|
|
|
|
{
|
|
|
|
Condition = ProfileConditionType.LessThanEqual,
|
|
|
|
IsRequired = false,
|
|
|
|
Property = ProfileConditionValue.AudioBitDepth,
|
|
|
|
Value = maxAudioBitDepth.Value.ToString(CultureInfo.InvariantCulture)
|
|
|
|
});
|
2020-08-01 12:38:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (maxAudioChannels.HasValue)
|
|
|
|
{
|
|
|
|
// codec profile
|
2021-01-24 12:32:29 +00:00
|
|
|
conditions.Add(
|
|
|
|
new ProfileCondition
|
|
|
|
{
|
|
|
|
Condition = ProfileConditionType.LessThanEqual,
|
|
|
|
IsRequired = false,
|
|
|
|
Property = ProfileConditionValue.AudioChannels,
|
|
|
|
Value = maxAudioChannels.Value.ToString(CultureInfo.InvariantCulture)
|
|
|
|
});
|
2020-08-01 12:38:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (conditions.Count > 0)
|
|
|
|
{
|
|
|
|
// codec profile
|
2021-01-24 12:32:29 +00:00
|
|
|
codecProfiles.Add(
|
|
|
|
new CodecProfile
|
|
|
|
{
|
|
|
|
Type = CodecType.Audio,
|
|
|
|
Container = string.Join(',', containers),
|
|
|
|
Conditions = conditions.ToArray()
|
|
|
|
});
|
2020-08-01 12:38:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
deviceProfile.CodecProfiles = codecProfiles.ToArray();
|
|
|
|
|
|
|
|
return deviceProfile;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|