add DisplayTitle to media streams

This commit is contained in:
Luke Pulverenti 2016-05-14 14:02:06 -04:00
parent 4d66f6dc6c
commit ff980dc42c
6 changed files with 147 additions and 5 deletions

View File

@ -460,7 +460,7 @@ namespace MediaBrowser.Api.Playback
// Boost volume to 200% when downsampling from 6ch to 2ch
if (channels.HasValue && channels.Value <= 2)
{
if (state.AudioStream != null && state.AudioStream.Channels.HasValue && state.AudioStream.Channels.Value > 5)
if (state.AudioStream != null && state.AudioStream.Channels.HasValue && state.AudioStream.Channels.Value > 5 && !ApiEntryPoint.Instance.GetEncodingOptions().DownMixAudioBoost.Equals(1))
{
volParam = ",volume=" + ApiEntryPoint.Instance.GetEncodingOptions().DownMixAudioBoost.ToString(UsCulture);
}

View File

@ -1008,7 +1008,7 @@ namespace MediaBrowser.MediaEncoding.Encoder
// Boost volume to 200% when downsampling from 6ch to 2ch
if (channels.HasValue && channels.Value <= 2)
{
if (state.AudioStream != null && state.AudioStream.Channels.HasValue && state.AudioStream.Channels.Value > 5)
if (state.AudioStream != null && state.AudioStream.Channels.HasValue && state.AudioStream.Channels.Value > 5 && !GetEncodingOptions().DownMixAudioBoost.Equals(1))
{
volParam = ",volume=" + GetEncodingOptions().DownMixAudioBoost.ToString(UsCulture);
}

View File

@ -432,6 +432,7 @@ namespace MediaBrowser.MediaEncoding.Probing
{
stream.Language = GetDictionaryValue(streamInfo.tags, "language");
stream.Comment = GetDictionaryValue(streamInfo.tags, "comment");
stream.Title = GetDictionaryValue(streamInfo.tags, "title");
}
if (string.Equals(streamInfo.codec_type, "audio", StringComparison.OrdinalIgnoreCase))
@ -540,9 +541,24 @@ namespace MediaBrowser.MediaEncoding.Probing
stream.IsForced = string.Equals(isForced, "1", StringComparison.OrdinalIgnoreCase);
}
NormalizeStreamTitle(stream);
return stream;
}
private void NormalizeStreamTitle(MediaStream stream)
{
if (string.Equals(stream.Title, "sdh", StringComparison.OrdinalIgnoreCase))
{
stream.Title = null;
}
if (stream.Type == MediaStreamType.EmbeddedImage)
{
stream.Title = null;
}
}
/// <summary>
/// Gets a string from an FFProbeResult tags dictionary
/// </summary>

View File

@ -1,4 +1,6 @@
using MediaBrowser.Model.Dlna;
using System;
using System.Collections.Generic;
using MediaBrowser.Model.Dlna;
using MediaBrowser.Model.Extensions;
using System.Diagnostics;
@ -34,6 +36,91 @@ namespace MediaBrowser.Model.Entities
/// <value>The comment.</value>
public string Comment { get; set; }
public string Title { get; set; }
public string DisplayTitle
{
get
{
if (!string.IsNullOrEmpty(Title))
{
return Title;
}
if (Type == MediaStreamType.Audio)
{
List<string> attributes = new List<string>();
if (!string.IsNullOrEmpty(Language))
{
attributes.Add(Language);
}
if (!string.IsNullOrEmpty(Codec) && !StringHelper.EqualsIgnoreCase(Codec, "dca"))
{
attributes.Add(Codec);
}
if (!string.IsNullOrEmpty(Profile) && !StringHelper.EqualsIgnoreCase(Profile, "lc"))
{
attributes.Add(Profile);
}
if (Channels.HasValue)
{
attributes.Add(StringHelper.ToStringCultureInvariant(Channels.Value) + " ch");
}
string name = string.Join(" ", attributes.ToArray());
if (IsDefault)
{
name += " (D)";
}
return name;
}
if (Type == MediaStreamType.Subtitle)
{
List<string> attributes = new List<string>();
if (!string.IsNullOrEmpty(Language))
{
attributes.Add(Language);
}
if (!string.IsNullOrEmpty(Codec))
{
attributes.Add(Codec);
}
string name = string.Join(" ", attributes.ToArray());
if (IsDefault)
{
name += " (D)";
}
if (IsForced)
{
name += " (F)";
}
if (IsExternal)
{
name += " (EXT)";
}
return name;
}
if (Type == MediaStreamType.Video)
{
}
return null;
}
}
public string NalLengthSize { get; set; }
/// <summary>

View File

@ -27,6 +27,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
AddCommentColumn();
AddNalColumn();
AddIsAvcColumn();
AddTitleColumn();
}
private void AddIsAvcColumn()
@ -60,6 +61,37 @@ namespace MediaBrowser.Server.Implementations.Persistence
_connection.RunQueries(new[] { builder.ToString() }, _logger);
}
private void AddTitleColumn()
{
using (var cmd = _connection.CreateCommand())
{
cmd.CommandText = "PRAGMA table_info(mediastreams)";
using (var reader = cmd.ExecuteReader(CommandBehavior.SequentialAccess | CommandBehavior.SingleResult))
{
while (reader.Read())
{
if (!reader.IsDBNull(1))
{
var name = reader.GetString(1);
if (string.Equals(name, "Title", StringComparison.OrdinalIgnoreCase))
{
return;
}
}
}
}
}
var builder = new StringBuilder();
builder.AppendLine("alter table mediastreams");
builder.AppendLine("add column Title TEXT");
_connection.RunQueries(new[] { builder.ToString() }, _logger);
}
private void AddNalColumn()
{
using (var cmd = _connection.CreateCommand())

View File

@ -120,7 +120,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
_connection = await dbConnector.Connect(dbFile).ConfigureAwait(false);
var createMediaStreamsTableCommand
= "create table if not exists mediastreams (ItemId GUID, StreamIndex INT, StreamType TEXT, Codec TEXT, Language TEXT, ChannelLayout TEXT, Profile TEXT, AspectRatio TEXT, Path TEXT, IsInterlaced BIT, BitRate INT NULL, Channels INT NULL, SampleRate INT NULL, IsDefault BIT, IsForced BIT, IsExternal BIT, Height INT NULL, Width INT NULL, AverageFrameRate FLOAT NULL, RealFrameRate FLOAT NULL, Level FLOAT NULL, PixelFormat TEXT, BitDepth INT NULL, IsAnamorphic BIT NULL, RefFrames INT NULL, CodecTag TEXT NULL, Comment TEXT NULL, NalLengthSize TEXT NULL, IsAvc BIT NULL, PRIMARY KEY (ItemId, StreamIndex))";
= "create table if not exists mediastreams (ItemId GUID, StreamIndex INT, StreamType TEXT, Codec TEXT, Language TEXT, ChannelLayout TEXT, Profile TEXT, AspectRatio TEXT, Path TEXT, IsInterlaced BIT, BitRate INT NULL, Channels INT NULL, SampleRate INT NULL, IsDefault BIT, IsForced BIT, IsExternal BIT, Height INT NULL, Width INT NULL, AverageFrameRate FLOAT NULL, RealFrameRate FLOAT NULL, Level FLOAT NULL, PixelFormat TEXT, BitDepth INT NULL, IsAnamorphic BIT NULL, RefFrames INT NULL, CodecTag TEXT NULL, Comment TEXT NULL, NalLengthSize TEXT NULL, IsAvc BIT NULL, Title TEXT NULL, PRIMARY KEY (ItemId, StreamIndex))";
string[] queries = {
@ -386,7 +386,8 @@ namespace MediaBrowser.Server.Implementations.Persistence
"CodecTag",
"Comment",
"NalLengthSize",
"IsAvc"
"IsAvc",
"Title"
};
/// <summary>
@ -3403,6 +3404,7 @@ namespace MediaBrowser.Server.Implementations.Persistence
_saveStreamCommand.GetParameter(index++).Value = stream.Comment;
_saveStreamCommand.GetParameter(index++).Value = stream.NalLengthSize;
_saveStreamCommand.GetParameter(index++).Value = stream.IsAVC;
_saveStreamCommand.GetParameter(index++).Value = stream.Title;
_saveStreamCommand.Transaction = transaction;
_saveStreamCommand.ExecuteNonQuery();
@ -3571,6 +3573,11 @@ namespace MediaBrowser.Server.Implementations.Persistence
item.IsAVC = reader.GetBoolean(28);
}
if (!reader.IsDBNull(29))
{
item.Title = reader.GetString(29);
}
return item;
}