update recording stop
This commit is contained in:
parent
f7e9e9f7a5
commit
a8296cba37
|
@ -1482,6 +1482,17 @@ namespace MediaBrowser.Api.Playback
|
|||
videoRequest.CopyTimestamps = string.Equals("true", val, StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
}
|
||||
else if (i == 25)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(val) && videoRequest != null)
|
||||
{
|
||||
SubtitleDeliveryMethod method;
|
||||
if (Enum.TryParse(val, out method))
|
||||
{
|
||||
videoRequest.SubtitleMethod = method;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -423,7 +423,24 @@ namespace MediaBrowser.Model.Dlna
|
|||
playlistItem.Container = transcodingProfile.Container;
|
||||
playlistItem.EstimateContentLength = transcodingProfile.EstimateContentLength;
|
||||
playlistItem.TranscodeSeekInfo = transcodingProfile.TranscodeSeekInfo;
|
||||
playlistItem.AudioCodec = transcodingProfile.AudioCodec.Split(',')[0];
|
||||
|
||||
// TODO: We should probably preserve the full list and sent it tp the server that way
|
||||
string[] supportedAudioCodecs = transcodingProfile.AudioCodec.Split(',');
|
||||
string inputAudioCodec = audioStream == null ? null : audioStream.Codec;
|
||||
foreach (string supportedAudioCodec in supportedAudioCodecs)
|
||||
{
|
||||
if (StringHelper.EqualsIgnoreCase(supportedAudioCodec, inputAudioCodec))
|
||||
{
|
||||
playlistItem.AudioCodec = supportedAudioCodec;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(playlistItem.AudioCodec))
|
||||
{
|
||||
playlistItem.AudioCodec = supportedAudioCodecs[0];
|
||||
}
|
||||
|
||||
playlistItem.VideoCodec = transcodingProfile.VideoCodec;
|
||||
playlistItem.CopyTimestamps = transcodingProfile.CopyTimestamps;
|
||||
playlistItem.SubProtocol = transcodingProfile.Protocol;
|
||||
|
|
|
@ -234,7 +234,8 @@ namespace MediaBrowser.Model.Dlna
|
|||
}
|
||||
|
||||
list.Add(new NameValuePair("CopyTimestamps", (item.CopyTimestamps).ToString().ToLower()));
|
||||
|
||||
list.Add(new NameValuePair("SubtitleMethod", item.SubtitleStreamIndex.HasValue && item.SubtitleDeliveryMethod != SubtitleDeliveryMethod.External ? item.SubtitleDeliveryMethod.ToString() : string.Empty));
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
|
|
|
@ -12,25 +12,21 @@ namespace MediaBrowser.Model.Session
|
|||
/// </summary>
|
||||
/// <value>The item.</value>
|
||||
public BaseItemInfo Item { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the item identifier.
|
||||
/// </summary>
|
||||
/// <value>The item identifier.</value>
|
||||
public string ItemId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the session id.
|
||||
/// </summary>
|
||||
/// <value>The session id.</value>
|
||||
public string SessionId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the media version identifier.
|
||||
/// </summary>
|
||||
/// <value>The media version identifier.</value>
|
||||
public string MediaSourceId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the position ticks.
|
||||
/// </summary>
|
||||
|
@ -46,5 +42,10 @@ namespace MediaBrowser.Model.Session
|
|||
/// </summary>
|
||||
/// <value>The play session identifier.</value>
|
||||
public string PlaySessionId { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether this <see cref="PlaybackStopInfo"/> is failed.
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if failed; otherwise, <c>false</c>.</value>
|
||||
public bool Failed { get; set; }
|
||||
}
|
||||
}
|
|
@ -28,6 +28,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
|
|||
private string _targetPath;
|
||||
private Process _process;
|
||||
private readonly IJsonSerializer _json;
|
||||
private readonly TaskCompletionSource<bool> _taskCompletionSource = new TaskCompletionSource<bool>();
|
||||
|
||||
public EncodedRecorder(ILogger logger, IFileSystem fileSystem, IMediaEncoder mediaEncoder, IApplicationPaths appPaths, IJsonSerializer json)
|
||||
{
|
||||
|
@ -93,11 +94,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
|
|||
// Important - don't await the log task or we won't be able to kill ffmpeg when the user stops playback
|
||||
StartStreamingLog(process.StandardError.BaseStream, _logFileStream);
|
||||
|
||||
// Wait for the file to exist before proceeeding
|
||||
while (!_hasExited)
|
||||
{
|
||||
await Task.Delay(100, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
await _taskCompletionSource.Task.ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private string GetCommandLineArgs(MediaSourceInfo mediaSource, string targetFile, TimeSpan duration)
|
||||
|
@ -197,16 +194,27 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
|
|||
{
|
||||
_hasExited = true;
|
||||
|
||||
_logger.Debug("Disposing stream resources");
|
||||
DisposeLogStream();
|
||||
|
||||
try
|
||||
{
|
||||
_logger.Info("FFMpeg exited with code {0}", process.ExitCode);
|
||||
var exitCode = process.ExitCode;
|
||||
|
||||
_logger.Info("FFMpeg recording exited with code {0} for {1}", exitCode, _targetPath);
|
||||
|
||||
if (exitCode == 0)
|
||||
{
|
||||
_taskCompletionSource.TrySetResult(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
_taskCompletionSource.TrySetException(new Exception(string.Format("Recording for {0} failed. Exit code {1}", _targetPath, exitCode)));
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
_logger.Error("FFMpeg exited with an error.");
|
||||
_logger.Error("FFMpeg recording exited with an error for {0}.", _targetPath);
|
||||
_taskCompletionSource.TrySetException(new Exception(string.Format("Recording for {0} failed", _targetPath)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -220,7 +228,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.ErrorException("Error disposing log stream", ex);
|
||||
_logger.ErrorException("Error disposing recording log stream", ex);
|
||||
}
|
||||
|
||||
_logFileStream = null;
|
||||
|
@ -250,7 +258,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV
|
|||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.ErrorException("Error reading ffmpeg log", ex);
|
||||
_logger.ErrorException("Error reading ffmpeg recording log", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -865,10 +865,13 @@ namespace MediaBrowser.Server.Implementations.LiveTv
|
|||
await _libraryManager.UpdateItem(item, ItemUpdateType.MetadataImport, cancellationToken).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
_providerManager.QueueRefresh(item.Id, new MetadataRefreshOptions(_fileSystem)
|
||||
if (info.Status != RecordingStatus.InProgress)
|
||||
{
|
||||
MetadataRefreshMode = metadataRefreshMode
|
||||
});
|
||||
_providerManager.QueueRefresh(item.Id, new MetadataRefreshOptions(_fileSystem)
|
||||
{
|
||||
MetadataRefreshMode = metadataRefreshMode
|
||||
});
|
||||
}
|
||||
|
||||
return item.Id;
|
||||
}
|
||||
|
|
|
@ -813,7 +813,7 @@ namespace MediaBrowser.Server.Implementations.Session
|
|||
|
||||
foreach (var user in users)
|
||||
{
|
||||
playedToCompletion = await OnPlaybackStopped(user.Id, key, libraryItem, info.PositionTicks).ConfigureAwait(false);
|
||||
playedToCompletion = await OnPlaybackStopped(user.Id, key, libraryItem, info.PositionTicks, info.Failed).ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -846,25 +846,29 @@ namespace MediaBrowser.Server.Implementations.Session
|
|||
await SendPlaybackStoppedNotification(session, CancellationToken.None).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private async Task<bool> OnPlaybackStopped(Guid userId, string userDataKey, BaseItem item, long? positionTicks)
|
||||
private async Task<bool> OnPlaybackStopped(Guid userId, string userDataKey, BaseItem item, long? positionTicks, bool playbackFailed)
|
||||
{
|
||||
var data = _userDataRepository.GetUserData(userId, userDataKey);
|
||||
bool playedToCompletion;
|
||||
bool playedToCompletion = false;
|
||||
|
||||
if (positionTicks.HasValue)
|
||||
if (!playbackFailed)
|
||||
{
|
||||
playedToCompletion = _userDataRepository.UpdatePlayState(item, data, positionTicks.Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
// If the client isn't able to report this, then we'll just have to make an assumption
|
||||
data.PlayCount++;
|
||||
data.Played = true;
|
||||
data.PlaybackPositionTicks = 0;
|
||||
playedToCompletion = true;
|
||||
}
|
||||
var data = _userDataRepository.GetUserData(userId, userDataKey);
|
||||
|
||||
if (positionTicks.HasValue)
|
||||
{
|
||||
playedToCompletion = _userDataRepository.UpdatePlayState(item, data, positionTicks.Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
// If the client isn't able to report this, then we'll just have to make an assumption
|
||||
data.PlayCount++;
|
||||
data.Played = true;
|
||||
data.PlaybackPositionTicks = 0;
|
||||
playedToCompletion = true;
|
||||
}
|
||||
|
||||
await _userDataRepository.SaveUserData(userId, item, data, UserDataSaveReason.PlaybackFinished, CancellationToken.None).ConfigureAwait(false);
|
||||
await _userDataRepository.SaveUserData(userId, item, data, UserDataSaveReason.PlaybackFinished, CancellationToken.None).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
return playedToCompletion;
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
|
||||
<metadata>
|
||||
<id>MediaBrowser.Common.Internal</id>
|
||||
<version>3.0.642</version>
|
||||
<version>3.0.643</version>
|
||||
<title>MediaBrowser.Common.Internal</title>
|
||||
<authors>Luke</authors>
|
||||
<owners>ebr,Luke,scottisafool</owners>
|
||||
|
@ -12,7 +12,7 @@
|
|||
<description>Contains common components shared by Emby Theater and Emby Server. Not intended for plugin developer consumption.</description>
|
||||
<copyright>Copyright © Emby 2013</copyright>
|
||||
<dependencies>
|
||||
<dependency id="MediaBrowser.Common" version="3.0.642" />
|
||||
<dependency id="MediaBrowser.Common" version="3.0.643" />
|
||||
<dependency id="NLog" version="4.2.3" />
|
||||
<dependency id="SimpleInjector" version="3.1.2" />
|
||||
</dependencies>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
|
||||
<metadata>
|
||||
<id>MediaBrowser.Common</id>
|
||||
<version>3.0.642</version>
|
||||
<version>3.0.643</version>
|
||||
<title>MediaBrowser.Common</title>
|
||||
<authors>Emby Team</authors>
|
||||
<owners>ebr,Luke,scottisafool</owners>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
|
||||
<metadata>
|
||||
<id>MediaBrowser.Model.Signed</id>
|
||||
<version>3.0.642</version>
|
||||
<version>3.0.643</version>
|
||||
<title>MediaBrowser.Model - Signed Edition</title>
|
||||
<authors>Emby Team</authors>
|
||||
<owners>ebr,Luke,scottisafool</owners>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
|
||||
<metadata>
|
||||
<id>MediaBrowser.Server.Core</id>
|
||||
<version>3.0.642</version>
|
||||
<version>3.0.643</version>
|
||||
<title>Media Browser.Server.Core</title>
|
||||
<authors>Emby Team</authors>
|
||||
<owners>ebr,Luke,scottisafool</owners>
|
||||
|
@ -12,7 +12,7 @@
|
|||
<description>Contains core components required to build plugins for Emby Server.</description>
|
||||
<copyright>Copyright © Emby 2013</copyright>
|
||||
<dependencies>
|
||||
<dependency id="MediaBrowser.Common" version="3.0.642" />
|
||||
<dependency id="MediaBrowser.Common" version="3.0.643" />
|
||||
<dependency id="Interfaces.IO" version="1.0.0.5" />
|
||||
</dependencies>
|
||||
</metadata>
|
||||
|
|
Loading…
Reference in New Issue
Block a user