expose more dlna profile properties

This commit is contained in:
Luke Pulverenti 2014-04-28 11:05:28 -04:00
parent 20507355eb
commit 0f4c28c120
6 changed files with 54 additions and 31 deletions

View file

@ -67,9 +67,6 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks.Tasks
/// <returns>Task.</returns> /// <returns>Task.</returns>
public async Task Execute(CancellationToken cancellationToken, IProgress<double> progress) public async Task Execute(CancellationToken cancellationToken, IProgress<double> progress)
{ {
if (!_appHost.CanSelfUpdate) return;
if (!ConfigurationManager.CommonConfiguration.EnableAutoUpdate) return;
EventHandler<double> innerProgressHandler = (sender, e) => progress.Report(e * .1); EventHandler<double> innerProgressHandler = (sender, e) => progress.Report(e * .1);
// Create a progress object for the update check // Create a progress object for the update check
@ -92,6 +89,8 @@ namespace MediaBrowser.Common.Implementations.ScheduledTasks.Tasks
cancellationToken.ThrowIfCancellationRequested(); cancellationToken.ThrowIfCancellationRequested();
if (!_appHost.CanSelfUpdate) return;
if (ConfigurationManager.CommonConfiguration.EnableAutoUpdate) if (ConfigurationManager.CommonConfiguration.EnableAutoUpdate)
{ {
Logger.Info("Update Revision {0} available. Updating...", updateInfo.AvailableVersion); Logger.Info("Update Revision {0} available. Updating...", updateInfo.AvailableVersion);

View file

@ -40,6 +40,13 @@ namespace MediaBrowser.Dlna.Ssdp
_logger = logger; _logger = logger;
_config = config; _config = config;
_serverSignature = serverSignature; _serverSignature = serverSignature;
_config.ConfigurationUpdated += _config_ConfigurationUpdated;
}
void _config_ConfigurationUpdated(object sender, EventArgs e)
{
ReloadAliveNotifier();
} }
public event EventHandler<SsdpMessageEventArgs> MessageReceived; public event EventHandler<SsdpMessageEventArgs> MessageReceived;
@ -69,7 +76,7 @@ namespace MediaBrowser.Dlna.Ssdp
_logger.Info("SSDP service started"); _logger.Info("SSDP service started");
Receive(); Receive();
StartNotificationTimer(); ReloadAliveNotifier();
} }
public void SendDatagram(string header, public void SendDatagram(string header,
@ -249,6 +256,8 @@ namespace MediaBrowser.Dlna.Ssdp
public void Dispose() public void Dispose()
{ {
_config.ConfigurationUpdated -= _config_ConfigurationUpdated;
_isDisposed = true; _isDisposed = true;
while (_messageQueue.Count != 0) while (_messageQueue.Count != 0)
{ {
@ -365,25 +374,34 @@ namespace MediaBrowser.Dlna.Ssdp
} }
private readonly object _notificationTimerSyncLock = new object(); private readonly object _notificationTimerSyncLock = new object();
private void StartNotificationTimer() private int _aliveNotifierIntervalMs;
private void ReloadAliveNotifier()
{ {
if (!_config.Configuration.DlnaOptions.BlastAliveMessages) if (!_config.Configuration.DlnaOptions.BlastAliveMessages)
{ {
DisposeNotificationTimer();
return; return;
} }
const int initialDelayMs = 3000;
var intervalMs = _config.Configuration.DlnaOptions.BlastAliveMessageIntervalSeconds * 1000; var intervalMs = _config.Configuration.DlnaOptions.BlastAliveMessageIntervalSeconds * 1000;
lock (_notificationTimerSyncLock) if (_notificationTimer == null || _aliveNotifierIntervalMs != intervalMs)
{ {
if (_notificationTimer == null) lock (_notificationTimerSyncLock)
{ {
_notificationTimer = new Timer(state => NotifyAll(), null, initialDelayMs, intervalMs); if (_notificationTimer == null)
} {
else _logger.Debug("Starting alive notifier");
{ const int initialDelayMs = 3000;
_notificationTimer.Change(initialDelayMs, intervalMs); _notificationTimer = new Timer(state => NotifyAll(), null, initialDelayMs, intervalMs);
}
else
{
_logger.Debug("Updating alive notifier");
_notificationTimer.Change(intervalMs, intervalMs);
}
_aliveNotifierIntervalMs = intervalMs;
} }
} }
} }
@ -394,6 +412,7 @@ namespace MediaBrowser.Dlna.Ssdp
{ {
if (_notificationTimer != null) if (_notificationTimer != null)
{ {
_logger.Debug("Stopping alive notifier");
_notificationTimer.Dispose(); _notificationTimer.Dispose();
_notificationTimer = null; _notificationTimer = null;
} }

View file

@ -87,6 +87,9 @@ namespace MediaBrowser.Model.Dlna
{ {
switch (condition.Property) switch (condition.Property)
{ {
case ProfileConditionValue.AudioProfile:
// TODO: Implement
return true;
case ProfileConditionValue.AudioBitrate: case ProfileConditionValue.AudioBitrate:
return IsConditionSatisfied(condition, audioBitrate); return IsConditionSatisfied(condition, audioBitrate);
case ProfileConditionValue.AudioChannels: case ProfileConditionValue.AudioChannels:

View file

@ -267,10 +267,11 @@ namespace MediaBrowser.Model.Dlna
get get
{ {
var stream = TargetAudioStream; var stream = TargetAudioStream;
var streamChannels = stream == null ? null : stream.Channels;
return MaxAudioChannels.HasValue && !IsDirectStream return MaxAudioChannels.HasValue && !IsDirectStream
? (stream.Channels.HasValue ? Math.Min(MaxAudioChannels.Value, stream.Channels.Value) : MaxAudioChannels.Value) ? (streamChannels.HasValue ? Math.Min(MaxAudioChannels.Value, streamChannels.Value) : MaxAudioChannels.Value)
: stream == null ? null : stream.Channels; : stream == null ? null : streamChannels;
} }
} }
@ -303,24 +304,14 @@ namespace MediaBrowser.Model.Dlna
if (RunTimeTicks.HasValue) if (RunTimeTicks.HasValue)
{ {
var totalBitrate = 0; var totalBitrate = TargetTotalBitrate;
if (AudioBitrate.HasValue) return totalBitrate.HasValue ?
{ Convert.ToInt64(totalBitrate * TimeSpan.FromTicks(RunTimeTicks.Value).TotalSeconds) :
totalBitrate += AudioBitrate.Value; (long?)null;
}
if (VideoBitrate.HasValue)
{
totalBitrate += VideoBitrate.Value;
}
return Convert.ToInt64(totalBitrate * TimeSpan.FromTicks(RunTimeTicks.Value).TotalSeconds);
} }
var stream = TargetAudioStream;
return MaxAudioChannels.HasValue && !IsDirectStream return null;
? (stream.Channels.HasValue ? Math.Min(MaxAudioChannels.Value, stream.Channels.Value) : MaxAudioChannels.Value)
: stream == null ? null : stream.Channels;
} }
} }
@ -343,7 +334,7 @@ namespace MediaBrowser.Model.Dlna
var defaultValue = string.Equals(Container, "m2ts", StringComparison.OrdinalIgnoreCase) var defaultValue = string.Equals(Container, "m2ts", StringComparison.OrdinalIgnoreCase)
? TransportStreamTimestamp.Valid ? TransportStreamTimestamp.Valid
: TransportStreamTimestamp.None; : TransportStreamTimestamp.None;
return !IsDirectStream return !IsDirectStream
? defaultValue ? defaultValue
: MediaSource == null ? defaultValue : MediaSource.Timestamp ?? TransportStreamTimestamp.None; : MediaSource == null ? defaultValue : MediaSource.Timestamp ?? TransportStreamTimestamp.None;

View file

@ -147,6 +147,13 @@ namespace MediaBrowser.Server.Implementations.EntryPoints.Notifications
var item = e.MediaInfo; var item = e.MediaInfo;
if (e.Item !=null && e.Item.Parent == null)
{
// Don't report theme song or local trailer playback
// TODO: This will also cause movie specials to not be reported
return;
}
var notification = new NotificationRequest var notification = new NotificationRequest
{ {
NotificationType = GetPlaybackNotificationType(item.MediaType), NotificationType = GetPlaybackNotificationType(item.MediaType),

View file

@ -1026,6 +1026,10 @@ namespace MediaBrowser.ServerApplication
/// <returns>Task{CheckForUpdateResult}.</returns> /// <returns>Task{CheckForUpdateResult}.</returns>
public override async Task<CheckForUpdateResult> CheckForApplicationUpdate(CancellationToken cancellationToken, IProgress<double> progress) public override async Task<CheckForUpdateResult> CheckForApplicationUpdate(CancellationToken cancellationToken, IProgress<double> progress)
{ {
#if DEBUG
return new CheckForUpdateResult { AvailableVersion = ApplicationVersion, IsUpdateAvailable = false };
#endif
var availablePackages = await InstallationManager.GetAvailablePackagesWithoutRegistrationInfo(cancellationToken).ConfigureAwait(false); var availablePackages = await InstallationManager.GetAvailablePackagesWithoutRegistrationInfo(cancellationToken).ConfigureAwait(false);
var version = InstallationManager.GetLatestCompatibleVersion(availablePackages, Constants.MbServerPkgName, null, ApplicationVersion, var version = InstallationManager.GetLatestCompatibleVersion(availablePackages, Constants.MbServerPkgName, null, ApplicationVersion,