adjust audio direct play checks

This commit is contained in:
Luke Pulverenti 2015-03-12 21:55:22 -04:00
parent aa64e1df78
commit 0ec38a9d40
7 changed files with 115 additions and 66 deletions

View file

@ -283,18 +283,20 @@ namespace MediaBrowser.Controller.Session
/// Gets the session by authentication token. /// Gets the session by authentication token.
/// </summary> /// </summary>
/// <param name="token">The token.</param> /// <param name="token">The token.</param>
/// <param name="deviceId">The device identifier.</param>
/// <param name="remoteEndpoint">The remote endpoint.</param> /// <param name="remoteEndpoint">The remote endpoint.</param>
/// <returns>SessionInfo.</returns> /// <returns>SessionInfo.</returns>
Task<SessionInfo> GetSessionByAuthenticationToken(string token, string remoteEndpoint); Task<SessionInfo> GetSessionByAuthenticationToken(string token, string deviceId, string remoteEndpoint);
/// <summary> /// <summary>
/// Gets the session by authentication token. /// Gets the session by authentication token.
/// </summary> /// </summary>
/// <param name="info">The information.</param> /// <param name="info">The information.</param>
/// <param name="deviceId">The device identifier.</param>
/// <param name="remoteEndpoint">The remote endpoint.</param> /// <param name="remoteEndpoint">The remote endpoint.</param>
/// <param name="appVersion">The application version.</param> /// <param name="appVersion">The application version.</param>
/// <returns>Task&lt;SessionInfo&gt;.</returns> /// <returns>Task&lt;SessionInfo&gt;.</returns>
Task<SessionInfo> GetSessionByAuthenticationToken(AuthenticationInfo info, string remoteEndpoint, string appVersion); Task<SessionInfo> GetSessionByAuthenticationToken(AuthenticationInfo info, string deviceId, string remoteEndpoint, string appVersion);
/// <summary> /// <summary>
/// Logouts the specified access token. /// Logouts the specified access token.

View file

@ -138,25 +138,12 @@ namespace MediaBrowser.Model.Dlna
DeviceProfile = options.Profile DeviceProfile = options.Profile
}; };
int? maxBitrateSetting = options.GetMaxBitrate(); List<PlayMethod> directPlayMethods = GetAudioDirectPlayMethods(item, options);
if (directPlayMethods.Count > 0)
{
MediaStream audioStream = item.DefaultAudioStream; MediaStream audioStream = item.DefaultAudioStream;
// Honor the max bitrate setting
if (IsAudioEligibleForDirectPlay(item, maxBitrateSetting))
{
DirectPlayProfile directPlay = null;
foreach (DirectPlayProfile i in options.Profile.DirectPlayProfiles)
{
if (i.Type == playlistItem.MediaType && IsAudioDirectPlaySupported(i, item, audioStream))
{
directPlay = i;
break;
}
}
if (directPlay != null)
{
string audioCodec = audioStream == null ? null : audioStream.Codec; string audioCodec = audioStream == null ? null : audioStream.Codec;
// Make sure audio codec profiles are satisfied // Make sure audio codec profiles are satisfied
@ -191,11 +178,13 @@ namespace MediaBrowser.Model.Dlna
if (all) if (all)
{ {
if (item.Protocol == MediaProtocol.File && _localPlayer.CanAccessFile(item.Path)) if (item.Protocol == MediaProtocol.File &&
directPlayMethods.Contains(PlayMethod.DirectPlay) &&
_localPlayer.CanAccessFile(item.Path))
{ {
playlistItem.PlayMethod = PlayMethod.DirectPlay; playlistItem.PlayMethod = PlayMethod.DirectPlay;
} }
else else if (directPlayMethods.Contains(PlayMethod.DirectStream))
{ {
playlistItem.PlayMethod = PlayMethod.DirectStream; playlistItem.PlayMethod = PlayMethod.DirectStream;
} }
@ -206,7 +195,6 @@ namespace MediaBrowser.Model.Dlna
} }
} }
} }
}
TranscodingProfile transcodingProfile = null; TranscodingProfile transcodingProfile = null;
foreach (TranscodingProfile i in options.Profile.TranscodingProfiles) foreach (TranscodingProfile i in options.Profile.TranscodingProfiles)
@ -272,6 +260,41 @@ namespace MediaBrowser.Model.Dlna
return playlistItem; return playlistItem;
} }
private List<PlayMethod> GetAudioDirectPlayMethods(MediaSourceInfo item, AudioOptions options)
{
MediaStream audioStream = item.DefaultAudioStream;
DirectPlayProfile directPlayProfile = null;
foreach (DirectPlayProfile i in options.Profile.DirectPlayProfiles)
{
if (i.Type == DlnaProfileType.Audio && IsAudioDirectPlaySupported(i, item, audioStream))
{
directPlayProfile = i;
break;
}
}
List<PlayMethod> playMethods = new List<PlayMethod>();
if (directPlayProfile != null)
{
// While options takes the network and other factors into account. Only applies to direct stream
if (IsAudioEligibleForDirectPlay(item, options.GetMaxBitrate()))
{
playMethods.Add(PlayMethod.DirectStream);
}
// The profile describes what the device supports
// If device requirements are satisfied then allow both direct stream and direct play
if (IsAudioEligibleForDirectPlay(item, options.Profile.MaxStaticBitrate))
{
playMethods.Add(PlayMethod.DirectPlay);
}
}
return playMethods;
}
private StreamInfo BuildVideoItem(MediaSourceInfo item, VideoOptions options) private StreamInfo BuildVideoItem(MediaSourceInfo item, VideoOptions options)
{ {
StreamInfo playlistItem = new StreamInfo StreamInfo playlistItem = new StreamInfo

View file

@ -252,7 +252,7 @@ namespace MediaBrowser.Providers.Manager
if (sourceHasAlbumArtist != null && targetHasAlbumArtist != null) if (sourceHasAlbumArtist != null && targetHasAlbumArtist != null)
{ {
if (replaceData || targetHasAlbumArtist.AlbumArtists.Count > 0) if (replaceData || targetHasAlbumArtist.AlbumArtists.Count == 0)
{ {
targetHasAlbumArtist.AlbumArtists = sourceHasAlbumArtist.AlbumArtists; targetHasAlbumArtist.AlbumArtists = sourceHasAlbumArtist.AlbumArtists;
} }

View file

@ -210,7 +210,15 @@ namespace MediaBrowser.Providers.MediaInfo
} }
} }
var albumArtist = FFProbeHelpers.GetDictionaryValue(tags, "albumartist") ?? FFProbeHelpers.GetDictionaryValue(tags, "album artist") ?? FFProbeHelpers.GetDictionaryValue(tags, "album_artist"); var albumArtist = FFProbeHelpers.GetDictionaryValue(tags, "albumartist");
if (string.IsNullOrWhiteSpace(albumArtist))
{
albumArtist = FFProbeHelpers.GetDictionaryValue(tags, "album artist");
}
if (string.IsNullOrWhiteSpace(albumArtist))
{
albumArtist = FFProbeHelpers.GetDictionaryValue(tags, "album_artist");
}
if (string.IsNullOrWhiteSpace(albumArtist)) if (string.IsNullOrWhiteSpace(albumArtist))
{ {
@ -277,8 +285,7 @@ namespace MediaBrowser.Providers.MediaInfo
return value.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries) return value.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries)
.Select(i => i.Trim()) .Select(i => i.Trim())
.Where(i => !string.IsNullOrWhiteSpace(i)) .FirstOrDefault(i => !string.IsNullOrWhiteSpace(i));
.FirstOrDefault();
} }
private readonly char[] _nameDelimiters = { '/', '|', ';', '\\' }; private readonly char[] _nameDelimiters = { '/', '|', ';', '\\' };

View file

@ -28,7 +28,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer.Security
if (!string.IsNullOrWhiteSpace(authorization.Token)) if (!string.IsNullOrWhiteSpace(authorization.Token))
{ {
var auth = GetTokenInfo(requestContext); var auth = GetTokenInfo(requestContext);
return _sessionManager.GetSessionByAuthenticationToken(auth, requestContext.RemoteIp, authorization.Version); return _sessionManager.GetSessionByAuthenticationToken(auth, authorization.DeviceId, requestContext.RemoteIp, authorization.Version);
} }
var session = _sessionManager.GetSession(authorization.DeviceId, authorization.Client, authorization.Version); var session = _sessionManager.GetSession(authorization.DeviceId, authorization.Client, authorization.Version);

View file

@ -1639,7 +1639,7 @@ namespace MediaBrowser.Server.Implementations.Session
string.Equals(i.Client, client)); string.Equals(i.Client, client));
} }
public Task<SessionInfo> GetSessionByAuthenticationToken(AuthenticationInfo info, string remoteEndpoint, string appVersion) public Task<SessionInfo> GetSessionByAuthenticationToken(AuthenticationInfo info, string deviceId, string remoteEndpoint, string appVersion)
{ {
if (info == null) if (info == null)
{ {
@ -1654,10 +1654,26 @@ namespace MediaBrowser.Server.Implementations.Session
? "1" ? "1"
: appVersion; : appVersion;
return GetSessionInfo(info.AppName, appVersion, info.DeviceId, info.DeviceName, remoteEndpoint, user); var deviceName = info.DeviceName;
if (!string.IsNullOrWhiteSpace(deviceId))
{
// Replace the info from the token with more recent info
var device = _deviceManager.GetDevice(deviceId);
if (device != null)
{
deviceName = device.Name;
}
}
else
{
deviceId = info.DeviceId;
} }
public Task<SessionInfo> GetSessionByAuthenticationToken(string token, string remoteEndpoint) return GetSessionInfo(info.AppName, appVersion, deviceId, deviceName, remoteEndpoint, user);
}
public Task<SessionInfo> GetSessionByAuthenticationToken(string token, string deviceId, string remoteEndpoint)
{ {
var result = _authRepo.Get(new AuthenticationInfoQuery var result = _authRepo.Get(new AuthenticationInfoQuery
{ {
@ -1676,7 +1692,7 @@ namespace MediaBrowser.Server.Implementations.Session
return null; return null;
} }
return GetSessionByAuthenticationToken(info, remoteEndpoint, null); return GetSessionByAuthenticationToken(info, deviceId, remoteEndpoint, null);
} }
public Task SendMessageToUserSessions<T>(string userId, string name, T data, public Task SendMessageToUserSessions<T>(string userId, string name, T data,

View file

@ -103,7 +103,8 @@ namespace MediaBrowser.Server.Implementations.Session
{ {
return Task.FromResult<SessionInfo>(null); return Task.FromResult<SessionInfo>(null);
} }
return _sessionManager.GetSessionByAuthenticationToken(token, remoteEndpoint); var deviceId = queryString["deviceId"];
return _sessionManager.GetSessionByAuthenticationToken(token, deviceId, remoteEndpoint);
} }
public void Dispose() public void Dispose()