sync updates

This commit is contained in:
Luke Pulverenti 2014-12-26 12:45:06 -05:00
parent 36577ac42e
commit 0ec3d217e7
46 changed files with 630 additions and 370 deletions

View File

@ -18,6 +18,7 @@ using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using MimeTypes = MediaBrowser.Model.Net.MimeTypes;
namespace MediaBrowser.Api.Images
{
@ -668,26 +669,26 @@ namespace MediaBrowser.Api.Images
{
if (format == ImageFormat.Bmp)
{
return Common.Net.MimeTypes.GetMimeType("i.bmp");
return MimeTypes.GetMimeType("i.bmp");
}
if (format == ImageFormat.Gif)
{
return Common.Net.MimeTypes.GetMimeType("i.gif");
return MimeTypes.GetMimeType("i.gif");
}
if (format == ImageFormat.Jpg)
{
return Common.Net.MimeTypes.GetMimeType("i.jpg");
return MimeTypes.GetMimeType("i.jpg");
}
if (format == ImageFormat.Png)
{
return Common.Net.MimeTypes.GetMimeType("i.png");
return MimeTypes.GetMimeType("i.png");
}
if (format == ImageFormat.Webp)
{
return Common.Net.MimeTypes.GetMimeType("i.webp");
return MimeTypes.GetMimeType("i.webp");
}
return Common.Net.MimeTypes.GetMimeType(path);
return MimeTypes.GetMimeType(path);
}
/// <summary>

View File

@ -14,6 +14,7 @@ using System.IO;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Model.Net;
namespace MediaBrowser.Api.Playback.Hls
{

View File

@ -20,6 +20,7 @@ using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using MimeTypes = MediaBrowser.Model.Net.MimeTypes;
namespace MediaBrowser.Api.Playback.Hls
{
@ -387,7 +388,7 @@ namespace MediaBrowser.Api.Playback.Hls
playlistText = GetMasterPlaylistFileText(state, videoBitrate + audioBitrate);
}
return ResultFactory.GetResult(playlistText, Common.Net.MimeTypes.GetMimeType("playlist.m3u8"), new Dictionary<string, string>());
return ResultFactory.GetResult(playlistText, MimeTypes.GetMimeType("playlist.m3u8"), new Dictionary<string, string>());
}
private string GetMasterPlaylistFileText(StreamState state, int totalBitrate)
@ -603,7 +604,7 @@ namespace MediaBrowser.Api.Playback.Hls
var playlistText = builder.ToString();
return ResultFactory.GetResult(playlistText, Common.Net.MimeTypes.GetMimeType("playlist.m3u8"), new Dictionary<string, string>());
return ResultFactory.GetResult(playlistText, MimeTypes.GetMimeType("playlist.m3u8"), new Dictionary<string, string>());
}
protected override string GetAudioArguments(StreamState state)
@ -640,10 +641,19 @@ namespace MediaBrowser.Api.Playback.Hls
{
var codec = state.OutputVideoCodec;
// See if we can save come cpu cycles by avoiding encoding
if (string.Equals(codec, "copy", StringComparison.OrdinalIgnoreCase))
var args = "-codec:v:0 " + codec;
if (state.EnableMpegtsM2TsMode)
{
return state.VideoStream != null && IsH264(state.VideoStream) ? "-codec:v:0 copy -bsf:v h264_mp4toannexb" : "-codec:v:0 copy";
args += " -mpegts_m2ts_mode 1";
}
// See if we can save come cpu cycles by avoiding encoding
if (codec.Equals("copy", StringComparison.OrdinalIgnoreCase))
{
return state.VideoStream != null && IsH264(state.VideoStream) ?
args + " -bsf:v h264_mp4toannexb" :
args;
}
var keyFrameArg = string.Format(" -force_key_frames expr:gte(t,n_forced*{0})",
@ -651,7 +661,7 @@ namespace MediaBrowser.Api.Playback.Hls
var hasGraphicalSubs = state.SubtitleStream != null && !state.SubtitleStream.IsTextSubtitleStream;
var args = "-codec:v:0 " + codec + " " + GetVideoQualityParam(state, H264Encoder, true) + keyFrameArg;
args += " " + GetVideoQualityParam(state, H264Encoder, true) + keyFrameArg;
// Add resolution params, if specified
if (!hasGraphicalSubs)

View File

@ -18,6 +18,7 @@ using System.Security;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using MimeTypes = MediaBrowser.Model.Net.MimeTypes;
namespace MediaBrowser.Api.Playback.Hls
{
@ -97,7 +98,7 @@ namespace MediaBrowser.Api.Playback.Hls
playlistText = GetManifestText(state);
}
return ResultFactory.GetResult(playlistText, Common.Net.MimeTypes.GetMimeType("playlist.mpd"), new Dictionary<string, string>());
return ResultFactory.GetResult(playlistText, MimeTypes.GetMimeType("playlist.mpd"), new Dictionary<string, string>());
}
private string GetManifestText(StreamState state)
@ -583,10 +584,19 @@ namespace MediaBrowser.Api.Playback.Hls
{
var codec = state.OutputVideoCodec;
var args = "-codec:v:0 " + codec;
if (state.EnableMpegtsM2TsMode)
{
args += " -mpegts_m2ts_mode 1";
}
// See if we can save come cpu cycles by avoiding encoding
if (codec.Equals("copy", StringComparison.OrdinalIgnoreCase))
{
return IsH264(state.VideoStream) ? "-codec:v:0 copy -bsf:v h264_mp4toannexb" : "-codec:v:0 copy";
return state.VideoStream != null && IsH264(state.VideoStream) ?
args + " -bsf:v h264_mp4toannexb" :
args;
}
var keyFrameArg = string.Format(" -force_key_frames expr:gte(t,n_forced*{0})",
@ -594,7 +604,7 @@ namespace MediaBrowser.Api.Playback.Hls
var hasGraphicalSubs = state.SubtitleStream != null && !state.SubtitleStream.IsTextSubtitleStream;
var args = "-codec:v:0 " + codec + " " + GetVideoQualityParam(state, H264Encoder, true) + keyFrameArg;
args+= " " + GetVideoQualityParam(state, H264Encoder, true) + keyFrameArg;
args += " -r 24 -g 24";

View File

@ -134,18 +134,27 @@ namespace MediaBrowser.Api.Playback.Hls
{
var codec = state.OutputVideoCodec;
var args = "-codec:v:0 " + codec;
if (state.EnableMpegtsM2TsMode)
{
args += " -mpegts_m2ts_mode 1";
}
// See if we can save come cpu cycles by avoiding encoding
if (codec.Equals("copy", StringComparison.OrdinalIgnoreCase))
{
return state.VideoStream != null && IsH264(state.VideoStream) ? "-codec:v:0 copy -bsf:v h264_mp4toannexb" : "-codec:v:0 copy";
return state.VideoStream != null && IsH264(state.VideoStream) ?
args + " -bsf:v h264_mp4toannexb" :
args;
}
var keyFrameArg = string.Format(" -force_key_frames expr:gte(t,n_forced*{0})",
state.SegmentLength.ToString(UsCulture));
var hasGraphicalSubs = state.SubtitleStream != null && !state.SubtitleStream.IsTextSubtitleStream;
var args = "-codec:v:0 " + codec + " " + GetVideoQualityParam(state, H264Encoder, true) + keyFrameArg;
args += " " + GetVideoQualityParam(state, H264Encoder, true) + keyFrameArg;
// Add resolution params, if specified
if (!hasGraphicalSubs)

View File

@ -124,7 +124,7 @@ namespace MediaBrowser.Api.Playback.Progressive
/// <returns>System.String.</returns>
private string GetVideoArguments(StreamState state, string codec)
{
var args = "-vcodec " + codec;
var args = "-codec:v:0 " + codec;
if (state.EnableMpegtsM2TsMode)
{
@ -134,7 +134,9 @@ namespace MediaBrowser.Api.Playback.Progressive
// See if we can save come cpu cycles by avoiding encoding
if (codec.Equals("copy", StringComparison.OrdinalIgnoreCase))
{
return state.VideoStream != null && IsH264(state.VideoStream) ? args + " -bsf:v h264_mp4toannexb" : args;
return state.VideoStream != null && IsH264(state.VideoStream) && string.Equals(state.OutputContainer, "ts", StringComparison.OrdinalIgnoreCase) ?
args + " -bsf:v h264_mp4toannexb" :
args;
}
var keyFrameArg = string.Format(" -force_key_frames expr:gte(t,n_forced*{0})",
@ -182,13 +184,13 @@ namespace MediaBrowser.Api.Playback.Progressive
// Get the output codec name
var codec = state.OutputAudioCodec;
var args = "-codec:a:0 " + codec;
if (codec.Equals("copy", StringComparison.OrdinalIgnoreCase))
{
return "-acodec copy";
return args;
}
var args = "-acodec " + codec;
// Add the number of audio channels
var channels = state.OutputAudioChannels;

View File

@ -11,6 +11,7 @@ using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Threading;
using MediaBrowser.Model.Net;
namespace MediaBrowser.Api.Playback
{

View File

@ -15,6 +15,7 @@ using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using MimeTypes = MediaBrowser.Model.Net.MimeTypes;
namespace MediaBrowser.Api.Subtitles
{
@ -175,7 +176,7 @@ namespace MediaBrowser.Api.Subtitles
builder.AppendLine("#EXT-X-ENDLIST");
return ResultFactory.GetResult(builder.ToString(), Common.Net.MimeTypes.GetMimeType("playlist.m3u8"), new Dictionary<string, string>());
return ResultFactory.GetResult(builder.ToString(), MimeTypes.GetMimeType("playlist.m3u8"), new Dictionary<string, string>());
}
public object Get(GetSubtitle request)
@ -199,7 +200,7 @@ namespace MediaBrowser.Api.Subtitles
var stream = GetSubtitles(request).Result;
return ResultFactory.GetResult(stream, Common.Net.MimeTypes.GetMimeType("file." + request.Format));
return ResultFactory.GetResult(stream, MimeTypes.GetMimeType("file." + request.Format));
}
private async Task<Stream> GetSubtitles(GetSubtitle request)
@ -240,7 +241,7 @@ namespace MediaBrowser.Api.Subtitles
{
var result = _subtitleManager.GetRemoteSubtitles(request.Id, CancellationToken.None).Result;
return ResultFactory.GetResult(result.Stream, Common.Net.MimeTypes.GetMimeType("file." + result.Format));
return ResultFactory.GetResult(result.Stream, MimeTypes.GetMimeType("file." + result.Format));
}
public void Post(DownloadRemoteSubtitles request)

View File

@ -5,6 +5,7 @@ using MediaBrowser.Controller.Sync;
using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Querying;
using MediaBrowser.Model.Sync;
using MediaBrowser.Model.Users;
using ServiceStack;
using System;
using System.Collections.Generic;
@ -60,7 +61,7 @@ namespace MediaBrowser.Api.Sync
[ApiMember(Name = "ParentId", Description = "ParentId", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
public string ParentId { get; set; }
[ApiMember(Name = "Category", Description = "Category", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")]
public SyncCategory? Category { get; set; }
}
@ -79,6 +80,11 @@ namespace MediaBrowser.Api.Sync
public string Id { get; set; }
}
[Route("/Sync/OfflineActions", "POST", Summary = "Reports an action that occurred while offline.")]
public class ReportOfflineActions : List<UserAction>, IReturnVoid
{
}
[Authenticated]
public class SyncService : BaseApiService
{
@ -173,9 +179,9 @@ namespace MediaBrowser.Api.Sync
.Select(i => _dtoService.GetBaseItemDto(i, new DtoOptions
{
Fields = new List<ItemFields>
{
ItemFields.SyncInfo
}
{
ItemFields.SyncInfo
}
}))
.ToList();
@ -184,5 +190,20 @@ namespace MediaBrowser.Api.Sync
return ToOptimizedResult(result);
}
public void Post(ReportOfflineActions request)
{
var task = PostAsync(request);
Task.WaitAll(task);
}
public async Task PostAsync(ReportOfflineActions request)
{
foreach (var action in request)
{
await _syncManager.ReportOfflineAction(action).ConfigureAwait(false);
}
}
}
}

View File

@ -74,7 +74,6 @@
<Compile Include="Net\INetworkManager.cs" />
<Compile Include="Net\IWebSocket.cs" />
<Compile Include="Net\IWebSocketConnection.cs" />
<Compile Include="Net\MimeTypes.cs" />
<Compile Include="Net\WebSocketConnectEventArgs.cs" />
<Compile Include="Net\WebSocketMessageInfo.cs" />
<Compile Include="Plugins\IDependencyModule.cs" />

View File

@ -61,5 +61,9 @@ namespace MediaBrowser.Controller.Library
/// <returns></returns>
Task SaveAllUserData(Guid userId, IEnumerable<UserItemData> userData, CancellationToken cancellationToken);
/// <summary>
/// Updates playstate for an item and returns true or false indicating if it was played to completion
/// </summary>
bool UpdatePlayState(BaseItem item, UserItemData data, long positionTicks);
}
}

View File

@ -4,6 +4,7 @@ using MediaBrowser.Model.Querying;
using MediaBrowser.Model.Sync;
using System.Collections.Generic;
using System.Threading.Tasks;
using MediaBrowser.Model.Users;
namespace MediaBrowser.Controller.Sync
{
@ -80,5 +81,19 @@ namespace MediaBrowser.Controller.Sync
/// <param name="id">The identifier.</param>
/// <returns>SyncJobItem.</returns>
SyncJobItem GetJobItem(string id);
/// <summary>
/// Gets the job item information.
/// </summary>
/// <param name="id">The identifier.</param>
/// <returns>SyncedItem.</returns>
SyncedItem GetJobItemInfo(string id);
/// <summary>
/// Reports the offline action.
/// </summary>
/// <param name="action">The action.</param>
/// <returns>Task.</returns>
Task ReportOfflineAction(UserAction action);
}
}

View File

@ -18,6 +18,7 @@ using System.Globalization;
using System.IO;
using System.Linq;
using System.Xml;
using MediaBrowser.Model.Net;
namespace MediaBrowser.Dlna.Didl
{

View File

@ -169,8 +169,8 @@ namespace MediaBrowser.LocalMetadata.Images
var names = new List<string>
{
"folder",
"cover",
"poster",
"cover",
"default"
};

View File

@ -10,8 +10,8 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>MediaBrowser.Model</RootNamespace>
<AssemblyName>MediaBrowser.Model</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Profile344</TargetFrameworkProfile>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkProfile>Profile259</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
@ -479,9 +479,6 @@
<Compile Include="..\MediaBrowser.Model\Dto\RecommendationType.cs">
<Link>Dto\RecommendationType.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\Dto\StreamOptions.cs">
<Link>Dto\StreamOptions.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\Dto\StudioDto.cs">
<Link>Dto\StudioDto.cs</Link>
</Compile>
@ -797,6 +794,12 @@
<Compile Include="..\MediaBrowser.Model\Net\HttpException.cs">
<Link>Net\HttpException.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\Net\HttpResponse.cs">
<Link>Net\HttpResponse.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\Net\MimeTypes.cs">
<Link>Net\MimeTypes.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\Net\NetworkShare.cs">
<Link>Net\NetworkShare.cs</Link>
</Compile>
@ -1037,18 +1040,24 @@
<Compile Include="..\MediaBrowser.Model\Session\UserDataChangeInfo.cs">
<Link>Session\UserDataChangeInfo.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\Sync\ItemFIleInfo.cs">
<Link>Sync\ItemFIleInfo.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\Sync\ItemFileType.cs">
<Link>Sync\ItemFileType.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\Sync\SyncCategory.cs">
<Link>Sync\SyncCategory.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\Sync\SyncDialogOptions.cs">
<Link>Sync\SyncDialogOptions.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\Sync\SyncedItem.cs">
<Link>Sync\SyncedItem.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\Sync\SyncHelper.cs">
<Link>Sync\SyncHelper.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\Sync\SyncItem.cs">
<Link>Sync\SyncItem.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\Sync\SyncJob.cs">
<Link>Sync\SyncJob.cs</Link>
</Compile>
@ -1151,6 +1160,12 @@
<Compile Include="..\MediaBrowser.Model\Users\PinRedeemResult.cs">
<Link>Users\PinRedeemResult.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\Users\UserAction.cs">
<Link>Users\UserAction.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\Users\UserActionType.cs">
<Link>Users\UserActionType.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\Users\UserPolicy.cs">
<Link>Users\UserPolicy.cs</Link>
</Compile>

View File

@ -444,9 +444,6 @@
<Compile Include="..\MediaBrowser.Model\Dto\RecommendationType.cs">
<Link>Dto\RecommendationType.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\Dto\StreamOptions.cs">
<Link>Dto\StreamOptions.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\Dto\StudioDto.cs">
<Link>Dto\StudioDto.cs</Link>
</Compile>
@ -756,6 +753,12 @@
<Compile Include="..\MediaBrowser.Model\Net\HttpException.cs">
<Link>Net\HttpException.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\Net\HttpResponse.cs">
<Link>Net\HttpResponse.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\Net\MimeTypes.cs">
<Link>Net\MimeTypes.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\Net\NetworkShare.cs">
<Link>Net\NetworkShare.cs</Link>
</Compile>
@ -996,18 +999,24 @@
<Compile Include="..\MediaBrowser.Model\Session\UserDataChangeInfo.cs">
<Link>Session\UserDataChangeInfo.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\Sync\ItemFIleInfo.cs">
<Link>Sync\ItemFIleInfo.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\Sync\ItemFileType.cs">
<Link>Sync\ItemFileType.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\Sync\SyncCategory.cs">
<Link>Sync\SyncCategory.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\Sync\SyncDialogOptions.cs">
<Link>Sync\SyncDialogOptions.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\Sync\SyncedItem.cs">
<Link>Sync\SyncedItem.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\Sync\SyncHelper.cs">
<Link>Sync\SyncHelper.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\Sync\SyncItem.cs">
<Link>Sync\SyncItem.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\Sync\SyncJob.cs">
<Link>Sync\SyncJob.cs</Link>
</Compile>
@ -1110,6 +1119,12 @@
<Compile Include="..\MediaBrowser.Model\Users\PinRedeemResult.cs">
<Link>Users\PinRedeemResult.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\Users\UserAction.cs">
<Link>Users\UserAction.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\Users\UserActionType.cs">
<Link>Users\UserActionType.cs</Link>
</Compile>
<Compile Include="..\MediaBrowser.Model\Users\UserPolicy.cs">
<Link>Users\UserPolicy.cs</Link>
</Compile>

View File

@ -7,6 +7,7 @@ using MediaBrowser.Model.Events;
using MediaBrowser.Model.Globalization;
using MediaBrowser.Model.LiveTv;
using MediaBrowser.Model.MediaInfo;
using MediaBrowser.Model.Net;
using MediaBrowser.Model.Notifications;
using MediaBrowser.Model.Playlists;
using MediaBrowser.Model.Plugins;
@ -185,6 +186,22 @@ namespace MediaBrowser.Model.ApiClient
/// <exception cref="ArgumentNullException">url</exception>
Task<Stream> GetImageStreamAsync(string url, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Gets the stream.
/// </summary>
/// <param name="url">The URL.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task&lt;Stream&gt;.</returns>
Task<Stream> GetStream(string url, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Gets the response.
/// </summary>
/// <param name="url">The URL.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task&lt;HttpResponse&gt;.</returns>
Task<HttpResponse> GetResponse(string url, CancellationToken cancellationToken = default(CancellationToken));
/// <summary>
/// Updates the user configuration.
/// </summary>
@ -1299,15 +1316,6 @@ namespace MediaBrowser.Model.ApiClient
/// <returns>Task&lt;QueryResult&lt;BaseItemDto&gt;&gt;.</returns>
Task<QueryResult<BaseItemDto>> GetPlaylistItems(PlaylistItemQuery query);
/// <summary>
/// Gets the url needed to stream an audio file
/// </summary>
/// <param name="options">The options.</param>
/// <returns>System.String.</returns>
/// <exception cref="ArgumentNullException">options</exception>
[Obsolete]
string GetAudioStreamUrl(StreamOptions options);
/// <summary>
/// Gets the url needed to stream a video file
/// </summary>
@ -1411,5 +1419,19 @@ namespace MediaBrowser.Model.ApiClient
/// <param name="webSocketFactory">The web socket factory.</param>
/// <param name="keepAliveTimerMs">The keep alive timer ms.</param>
void OpenWebSocket(Func<IClientWebSocket> webSocketFactory, int keepAliveTimerMs = 60000);
/// <summary>
/// Reports the offline actions.
/// </summary>
/// <param name="actions">The actions.</param>
/// <returns>Task.</returns>
Task ReportOfflineActions(List<UserAction> actions);
/// <summary>
/// Gets the ready synchronize items.
/// </summary>
/// <param name="targetId">The target identifier.</param>
/// <returns>List&lt;SyncedItem&gt;.</returns>
Task<List<SyncedItem>> GetReadySyncItems(string targetId);
}
}

View File

@ -1,67 +0,0 @@
using System;
namespace MediaBrowser.Model.Dto
{
/// <summary>
/// Class StreamOptions
/// </summary>
[Obsolete]
public class StreamOptions
{
/// <summary>
/// Gets or sets the audio bit rate.
/// </summary>
/// <value>The audio bit rate.</value>
public int? AudioBitRate { get; set; }
/// <summary>
/// Gets or sets the audio codec.
/// Omit to copy the original stream
/// </summary>
/// <value>The audio encoding format.</value>
public string AudioCodec { get; set; }
/// <summary>
/// Gets or sets the item id.
/// </summary>
/// <value>The item id.</value>
public string ItemId { get; set; }
/// <summary>
/// Gets or sets the max audio channels.
/// </summary>
/// <value>The max audio channels.</value>
public int? MaxAudioChannels { get; set; }
/// <summary>
/// Gets or sets the max audio sample rate.
/// </summary>
/// <value>The max audio sample rate.</value>
public int? MaxAudioSampleRate { get; set; }
/// <summary>
/// Gets or sets the start time ticks.
/// </summary>
/// <value>The start time ticks.</value>
public long? StartTimeTicks { get; set; }
/// <summary>
/// Gets or sets a value indicating whether the original media should be served statically
/// Only used with progressive streaming
/// </summary>
/// <value><c>true</c> if static; otherwise, <c>false</c>.</value>
public bool? Static { get; set; }
/// <summary>
/// Gets or sets the output file extension.
/// </summary>
/// <value>The output file extension.</value>
public string OutputFileExtension { get; set; }
/// <summary>
/// Gets or sets the device id.
/// </summary>
/// <value>The device id.</value>
public string DeviceId { get; set; }
}
}

View File

@ -6,8 +6,64 @@ namespace MediaBrowser.Model.Dto
/// Class VideoStreamOptions
/// </summary>
[Obsolete]
public class VideoStreamOptions : StreamOptions
public class VideoStreamOptions
{
/// <summary>
/// Gets or sets the audio bit rate.
/// </summary>
/// <value>The audio bit rate.</value>
public int? AudioBitRate { get; set; }
/// <summary>
/// Gets or sets the audio codec.
/// Omit to copy the original stream
/// </summary>
/// <value>The audio encoding format.</value>
public string AudioCodec { get; set; }
/// <summary>
/// Gets or sets the item id.
/// </summary>
/// <value>The item id.</value>
public string ItemId { get; set; }
/// <summary>
/// Gets or sets the max audio channels.
/// </summary>
/// <value>The max audio channels.</value>
public int? MaxAudioChannels { get; set; }
/// <summary>
/// Gets or sets the max audio sample rate.
/// </summary>
/// <value>The max audio sample rate.</value>
public int? MaxAudioSampleRate { get; set; }
/// <summary>
/// Gets or sets the start time ticks.
/// </summary>
/// <value>The start time ticks.</value>
public long? StartTimeTicks { get; set; }
/// <summary>
/// Gets or sets a value indicating whether the original media should be served statically
/// Only used with progressive streaming
/// </summary>
/// <value><c>true</c> if static; otherwise, <c>false</c>.</value>
public bool? Static { get; set; }
/// <summary>
/// Gets or sets the output file extension.
/// </summary>
/// <value>The output file extension.</value>
public string OutputFileExtension { get; set; }
/// <summary>
/// Gets or sets the device id.
/// </summary>
/// <value>The device id.</value>
public string DeviceId { get; set; }
/// <summary>
/// Gets or sets the video codec.
/// Omit to copy

View File

@ -133,7 +133,6 @@
<Compile Include="Dto\NameValuePair.cs" />
<Compile Include="MediaInfo\LiveMediaInfoResult.cs" />
<Compile Include="Dto\MediaSourceType.cs" />
<Compile Include="Dto\StreamOptions.cs" />
<Compile Include="Dto\VideoStreamOptions.cs" />
<Compile Include="Configuration\DynamicDayOfWeek.cs" />
<Compile Include="Entities\ExtraType.cs" />
@ -155,6 +154,8 @@
<Compile Include="Configuration\MetadataPluginType.cs" />
<Compile Include="Dlna\SubtitleProfile.cs" />
<Compile Include="MediaInfo\MediaProtocol.cs" />
<Compile Include="Net\HttpResponse.cs" />
<Compile Include="Net\MimeTypes.cs" />
<Compile Include="Notifications\NotificationOption.cs" />
<Compile Include="Notifications\NotificationOptions.cs" />
<Compile Include="Notifications\NotificationType.cs" />
@ -366,10 +367,12 @@
<Compile Include="Session\TranscodingInfo.cs" />
<Compile Include="Session\UserDataChangeInfo.cs" />
<Compile Include="Devices\ContentUploadHistory.cs" />
<Compile Include="Sync\ItemFIleInfo.cs" />
<Compile Include="Sync\ItemFileType.cs" />
<Compile Include="Sync\SyncCategory.cs" />
<Compile Include="Sync\SyncDialogOptions.cs" />
<Compile Include="Sync\SyncedItem.cs" />
<Compile Include="Sync\SyncHelper.cs" />
<Compile Include="Sync\SyncItem.cs" />
<Compile Include="Sync\SyncJob.cs" />
<Compile Include="Sync\SyncJobCreationResult.cs" />
<Compile Include="Sync\SyncJobItem.cs" />
@ -423,6 +426,8 @@
<Compile Include="Users\ForgotPasswordAction.cs" />
<Compile Include="Users\ForgotPasswordResult.cs" />
<Compile Include="Users\PinRedeemResult.cs" />
<Compile Include="Users\UserAction.cs" />
<Compile Include="Users\UserActionType.cs" />
<Compile Include="Users\UserPolicy.cs" />
<None Include="Fody.targets" />
<None Include="FodyWeavers.xml" />

View File

@ -0,0 +1,64 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
namespace MediaBrowser.Model.Net
{
public class HttpResponse : IDisposable
{
/// <summary>
/// Gets or sets the type of the content.
/// </summary>
/// <value>The type of the content.</value>
public string ContentType { get; set; }
/// <summary>
/// Gets or sets the response URL.
/// </summary>
/// <value>The response URL.</value>
public string ResponseUrl { get; set; }
/// <summary>
/// Gets or sets the content.
/// </summary>
/// <value>The content.</value>
public Stream Content { get; set; }
/// <summary>
/// Gets or sets the status code.
/// </summary>
/// <value>The status code.</value>
public HttpStatusCode StatusCode { get; set; }
/// <summary>
/// Gets or sets the length of the content.
/// </summary>
/// <value>The length of the content.</value>
public long? ContentLength { get; set; }
/// <summary>
/// Gets or sets the headers.
/// </summary>
/// <value>The headers.</value>
public Dictionary<string, string> Headers { get; set; }
private readonly IDisposable _disposable;
public HttpResponse(IDisposable disposable)
{
_disposable = disposable;
}
public HttpResponse()
{
}
public void Dispose()
{
if (_disposable != null)
{
_disposable.Dispose();
}
}
}
}

View File

@ -3,18 +3,13 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace MediaBrowser.Common.Net
namespace MediaBrowser.Model.Net
{
/// <summary>
/// Class MimeTypes
/// </summary>
public static class MimeTypes
{
/// <summary>
/// The json MIME type
/// </summary>
public static string JsonMimeType = "application/json";
/// <summary>
/// Any extension in this list is considered a video file - can be added to at runtime for extensibility
/// </summary>
@ -52,35 +47,44 @@ namespace MediaBrowser.Common.Net
private static readonly Dictionary<string, string> VideoFileExtensionsDictionary = VideoFileExtensions.ToDictionary(i => i, StringComparer.OrdinalIgnoreCase);
/// <summary>
/// Determines whether [is video file] [the specified path].
/// </summary>
/// <param name="path">The path.</param>
/// <returns><c>true</c> if [is video file] [the specified path]; otherwise, <c>false</c>.</returns>
public static bool IsVideoFile(string path)
{
if (string.IsNullOrEmpty(path))
// http://en.wikipedia.org/wiki/Internet_media_type
// Add more as needed
private static readonly Dictionary<string, string> MimeTypeLookup =
new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
{
throw new ArgumentNullException("path");
}
var extension = Path.GetExtension(path);
if (string.IsNullOrEmpty(extension))
{
return false;
}
return VideoFileExtensionsDictionary.ContainsKey(extension);
}
{".jpg", "image/jpeg"},
{".jpeg", "image/jpeg"},
{".tbn", "image/jpeg"},
{".png", "image/png"},
{".gif", "image/gif"},
{".webp", "image/webp"},
{".ico", "image/vnd.microsoft.icon"},
{".mpg", "video/mpeg"},
{".mpeg", "video/mpeg"},
{".ogv", "video/ogg"},
{".mov", "video/quicktime"},
{".webm", "video/webm"},
{".mkv", "video/x-matroska"},
{".wmv", "video/x-ms-wmv"},
{".flv", "video/x-flv"},
{".avi", "video/x-msvideo"},
{".asf", "video/x-ms-asf"},
{".m4v", "video/x-m4v"}
};
private static readonly Dictionary<string, string> ExtensionLookup =
MimeTypeLookup
.GroupBy(i => i.Value)
.ToDictionary(x => x.Key, x => x.First().Key, StringComparer.OrdinalIgnoreCase);
/// <summary>
/// Gets the type of the MIME.
/// </summary>
/// <param name="path">The path.</param>
/// <returns>System.String.</returns>
/// <exception cref="System.ArgumentNullException">path</exception>
/// <exception cref="System.InvalidOperationException">Argument not supported: + path</exception>
/// <exception cref="ArgumentNullException">path</exception>
/// <exception cref="InvalidOperationException">Argument not supported: + path</exception>
public static string GetMimeType(string path)
{
if (string.IsNullOrEmpty(path))
@ -90,50 +94,13 @@ namespace MediaBrowser.Common.Net
var ext = Path.GetExtension(path) ?? string.Empty;
// http://en.wikipedia.org/wiki/Internet_media_type
// Add more as needed
string result;
if (MimeTypeLookup.TryGetValue(ext, out result))
{
return result;
}
// Type video
if (ext.Equals(".mpg", StringComparison.OrdinalIgnoreCase) || ext.EndsWith("mpeg", StringComparison.OrdinalIgnoreCase))
{
return "video/mpeg";
}
if (ext.Equals(".ogv", StringComparison.OrdinalIgnoreCase))
{
return "video/ogg";
}
if (ext.Equals(".mov", StringComparison.OrdinalIgnoreCase))
{
return "video/quicktime";
}
if (ext.Equals(".webm", StringComparison.OrdinalIgnoreCase))
{
return "video/webm";
}
if (ext.Equals(".mkv", StringComparison.OrdinalIgnoreCase))
{
return "video/x-matroska";
}
if (ext.Equals(".wmv", StringComparison.OrdinalIgnoreCase))
{
return "video/x-ms-wmv";
}
if (ext.Equals(".flv", StringComparison.OrdinalIgnoreCase))
{
return "video/x-flv";
}
if (ext.Equals(".avi", StringComparison.OrdinalIgnoreCase))
{
return "video/x-msvideo";
}
if (ext.Equals(".m4v", StringComparison.OrdinalIgnoreCase))
{
return "video/x-m4v";
}
if (ext.EndsWith("asf", StringComparison.OrdinalIgnoreCase))
{
return "video/x-ms-asf";
}
if (ext.Equals(".3gp", StringComparison.OrdinalIgnoreCase))
{
return "video/3gpp";
@ -197,28 +164,6 @@ namespace MediaBrowser.Common.Net
return "application/x-cdisplay";
}
// Type image
if (ext.Equals(".gif", StringComparison.OrdinalIgnoreCase))
{
return "image/gif";
}
if (ext.Equals(".jpg", StringComparison.OrdinalIgnoreCase) || ext.Equals(".jpeg", StringComparison.OrdinalIgnoreCase) || ext.Equals(".tbn", StringComparison.OrdinalIgnoreCase))
{
return "image/jpeg";
}
if (ext.Equals(".png", StringComparison.OrdinalIgnoreCase))
{
return "image/png";
}
if (ext.Equals(".webp", StringComparison.OrdinalIgnoreCase))
{
return "image/webp";
}
if (ext.Equals(".ico", StringComparison.OrdinalIgnoreCase))
{
return "image/vnd.microsoft.icon";
}
// Type audio
if (ext.Equals(".mp3", StringComparison.OrdinalIgnoreCase))
{
@ -272,7 +217,7 @@ namespace MediaBrowser.Common.Net
}
if (ext.Equals(".json", StringComparison.OrdinalIgnoreCase))
{
return JsonMimeType;
return "application/json";
}
if (ext.Equals(".map", StringComparison.OrdinalIgnoreCase))
{
@ -320,19 +265,9 @@ namespace MediaBrowser.Common.Net
throw new ArgumentException("Argument not supported: " + path);
}
private static readonly Dictionary<string, string> MimeExtensions =
new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase)
{
{"image/jpeg", "jpg"},
{"image/jpg", "jpg"},
{"image/png", "png"},
{"image/gif", "gif"},
{"image/webp", "webp"}
};
public static string ToExtension(string mimeType)
{
return "." + MimeExtensions[mimeType];
return ExtensionLookup[mimeType];
}
}
}

View File

@ -0,0 +1,28 @@
using MediaBrowser.Model.Entities;
namespace MediaBrowser.Model.Sync
{
public class ItemFileInfo
{
/// <summary>
/// Gets or sets the type.
/// </summary>
/// <value>The type.</value>
public ItemFileType Type { 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 name.
/// </summary>
/// <value>The name.</value>
public string Name { get; set; }
/// <summary>
/// Gets or sets the type of the image.
/// </summary>
/// <value>The type of the image.</value>
public ImageType ImageType { get; set; }
}
}

View File

@ -0,0 +1,19 @@

namespace MediaBrowser.Model.Sync
{
public enum ItemFileType
{
/// <summary>
/// The media
/// </summary>
Media = 0,
/// <summary>
/// The image
/// </summary>
Image = 1,
/// <summary>
/// The subtitles
/// </summary>
Subtitles = 2
}
}

View File

@ -1,9 +0,0 @@
using MediaBrowser.Model.Dto;
namespace MediaBrowser.Model.Sync
{
public class SyncItem
{
public BaseItemDto Item { get; set; }
}
}

View File

@ -22,6 +22,12 @@ namespace MediaBrowser.Model.Sync
/// <value>The item identifier.</value>
public string ItemId { get; set; }
/// <summary>
/// Gets or sets the media source identifier.
/// </summary>
/// <value>The media source identifier.</value>
public string MediaSourceId { get; set; }
/// <summary>
/// Gets or sets the target identifier.
/// </summary>

View File

@ -0,0 +1,38 @@
using MediaBrowser.Model.Dto;
namespace MediaBrowser.Model.Sync
{
public class SyncedItem
{
/// <summary>
/// Gets or sets the server identifier.
/// </summary>
/// <value>The server identifier.</value>
public string ServerId { get; set; }
/// <summary>
/// Gets or sets the synchronize job identifier.
/// </summary>
/// <value>The synchronize job identifier.</value>
public string SyncJobId { get; set; }
/// <summary>
/// Gets or sets the synchronize job item identifier.
/// </summary>
/// <value>The synchronize job item identifier.</value>
public string SyncJobItemId { get; set; }
/// <summary>
/// Gets or sets the name of the original file.
/// </summary>
/// <value>The name of the original file.</value>
public string OriginalFileName { get; set; }
/// <summary>
/// Gets or sets the item.
/// </summary>
/// <value>The item.</value>
public BaseItemDto Item { get; set; }
/// <summary>
/// Gets or sets the user identifier.
/// </summary>
/// <value>The user identifier.</value>
public string UserId { get; set; }
}
}

View File

@ -0,0 +1,14 @@
using System;
namespace MediaBrowser.Model.Users
{
public class UserAction
{
public string ServerId { get; set; }
public string UserId { get; set; }
public string ItemId { get; set; }
public UserActionType Type { get; set; }
public DateTime Date { get; set; }
public long? PositionTicks { get; set; }
}
}

View File

@ -0,0 +1,8 @@

namespace MediaBrowser.Model.Users
{
public enum UserActionType
{
PlayedItem = 0
}
}

View File

@ -16,6 +16,7 @@ using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using MediaBrowser.Model.Net;
namespace MediaBrowser.Providers.Manager
{

View File

@ -34,7 +34,7 @@ namespace MediaBrowser.Server.Implementations.Connect
{
LoadCachedAddress();
_timer = new Timer(TimerCallback, null, TimeSpan.FromSeconds(10), TimeSpan.FromHours(6));
_timer = new Timer(TimerCallback, null, TimeSpan.FromSeconds(5), TimeSpan.FromHours(3));
}
private async void TimerCallback(object state)

View File

@ -12,7 +12,7 @@ using System.IO;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using MimeTypes = MediaBrowser.Common.Net.MimeTypes;
using MimeTypes = MediaBrowser.Model.Net.MimeTypes;
namespace MediaBrowser.Server.Implementations.HttpServer
{

View File

@ -30,12 +30,6 @@ namespace MediaBrowser.Server.Implementations.Library.Resolvers.Movies
{
return null;
}
// This is a bit of a one-off but it's here to combat MCM's over-aggressive placement of collection.xml files where they don't belong, including in series folders.
if (args.ContainsMetaFileByName("series.xml"))
{
return null;
}
if (filename.IndexOf("[boxset]", StringComparison.OrdinalIgnoreCase) != -1 ||
args.ContainsFileSystemEntryByName("collection.xml"))

View File

@ -1,6 +1,8 @@
using System.Collections.Generic;
using MediaBrowser.Common.Events;
using MediaBrowser.Controller.Configuration;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.Persistence;
using MediaBrowser.Model.Dto;
@ -23,9 +25,11 @@ namespace MediaBrowser.Server.Implementations.Library
private readonly ConcurrentDictionary<string, UserItemData> _userData = new ConcurrentDictionary<string, UserItemData>();
private readonly ILogger _logger;
private readonly IServerConfigurationManager _config;
public UserDataManager(ILogManager logManager)
public UserDataManager(ILogManager logManager, IServerConfigurationManager config)
{
_config = config;
_logger = logManager.GetLogger(GetType().Name);
}
@ -35,22 +39,6 @@ namespace MediaBrowser.Server.Implementations.Library
/// <value>The repository.</value>
public IUserDataRepository Repository { get; set; }
/// <summary>
/// Saves the user data.
/// </summary>
/// <param name="userId">The user id.</param>
/// <param name="item">The item.</param>
/// <param name="userData">The user data.</param>
/// <param name="reason">The reason.</param>
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>Task.</returns>
/// <exception cref="System.ArgumentNullException">userData
/// or
/// cancellationToken
/// or
/// userId
/// or
/// key</exception>
public async Task SaveUserData(Guid userId, IHasUserData item, UserItemData userData, UserDataSaveReason reason, CancellationToken cancellationToken)
{
if (userData == null)
@ -219,5 +207,59 @@ namespace MediaBrowser.Server.Implementations.Library
Key = data.Key
};
}
public bool UpdatePlayState(BaseItem item, UserItemData data, long positionTicks)
{
var playedToCompletion = false;
var hasRuntime = item.RunTimeTicks.HasValue && item.RunTimeTicks > 0;
// If a position has been reported, and if we know the duration
if (positionTicks > 0 && hasRuntime)
{
var pctIn = Decimal.Divide(positionTicks, item.RunTimeTicks.Value) * 100;
// Don't track in very beginning
if (pctIn < _config.Configuration.MinResumePct)
{
positionTicks = 0;
}
// If we're at the end, assume completed
else if (pctIn > _config.Configuration.MaxResumePct || positionTicks >= item.RunTimeTicks.Value)
{
positionTicks = 0;
data.Played = playedToCompletion = true;
}
else
{
// Enforce MinResumeDuration
var durationSeconds = TimeSpan.FromTicks(item.RunTimeTicks.Value).TotalSeconds;
if (durationSeconds < _config.Configuration.MinResumeDurationSeconds)
{
positionTicks = 0;
data.Played = playedToCompletion = true;
}
}
}
else if (!hasRuntime)
{
// If we don't know the runtime we'll just have to assume it was fully played
data.Played = playedToCompletion = true;
positionTicks = 0;
}
if (item is Audio)
{
positionTicks = 0;
}
data.PlaybackPositionTicks = positionTicks;
return playedToCompletion;
}
}
}

View File

@ -251,7 +251,6 @@
"HeaderDeleteItem": "Delete Item",
"ConfirmDeleteItem": "Are you sure you wish to delete this item from your library?",
"MessagePleaseEnterNameOrId": "Please enter a name or an external Id.",
"MessageValueNotCorrect": "The value entered is not correct. Please try again.",
"MessageItemSaved": "Item saved.",
"OptionEnded": "Ended",
"OptionContinuing": "Continuing",

View File

@ -252,7 +252,7 @@
"ButtonMoveRight": "Move right",
"ButtonBrowseOnlineImages": "Browse online images",
"HeaderDeleteItem": "Delete Item",
"ConfirmDeleteItem": "Are you sure you wish to delete this item from your library?",
"ConfirmDeleteItem": "Deleting this item will delete it from both the file system and your media library. Are you sure you wish to continue?",
"MessagePleaseEnterNameOrId": "Please enter a name or an external Id.",
"MessageValueNotCorrect": "The value entered is not correct. Please try again.",
"MessageItemSaved": "Item saved.",

View File

@ -67,12 +67,6 @@ namespace MediaBrowser.Server.Implementations.Session
private readonly IAuthenticationRepository _authRepo;
private readonly IDeviceManager _deviceManager;
/// <summary>
/// Gets or sets the configuration manager.
/// </summary>
/// <value>The configuration manager.</value>
private readonly IServerConfigurationManager _configurationManager;
/// <summary>
/// The _active connections
/// </summary>
@ -105,18 +99,9 @@ namespace MediaBrowser.Server.Implementations.Session
private readonly SemaphoreSlim _sessionLock = new SemaphoreSlim(1, 1);
/// <summary>
/// Initializes a new instance of the <see cref="SessionManager" /> class.
/// </summary>
/// <param name="userDataRepository">The user data repository.</param>
/// <param name="configurationManager">The configuration manager.</param>
/// <param name="logger">The logger.</param>
/// <param name="userRepository">The user repository.</param>
/// <param name="libraryManager">The library manager.</param>
public SessionManager(IUserDataManager userDataRepository, IServerConfigurationManager configurationManager, ILogger logger, IUserRepository userRepository, ILibraryManager libraryManager, IUserManager userManager, IMusicManager musicManager, IDtoService dtoService, IImageProcessor imageProcessor, IItemRepository itemRepo, IJsonSerializer jsonSerializer, IServerApplicationHost appHost, IHttpClient httpClient, IAuthenticationRepository authRepo, IDeviceManager deviceManager)
public SessionManager(IUserDataManager userDataRepository, ILogger logger, IUserRepository userRepository, ILibraryManager libraryManager, IUserManager userManager, IMusicManager musicManager, IDtoService dtoService, IImageProcessor imageProcessor, IItemRepository itemRepo, IJsonSerializer jsonSerializer, IServerApplicationHost appHost, IHttpClient httpClient, IAuthenticationRepository authRepo, IDeviceManager deviceManager)
{
_userDataRepository = userDataRepository;
_configurationManager = configurationManager;
_logger = logger;
_userRepository = userRepository;
_libraryManager = libraryManager;
@ -689,7 +674,7 @@ namespace MediaBrowser.Server.Implementations.Session
if (positionTicks.HasValue)
{
UpdatePlayState(item, data, positionTicks.Value);
_userDataRepository.UpdatePlayState(item, data, positionTicks.Value);
await _userDataRepository.SaveUserData(userId, item, data, UserDataSaveReason.PlaybackProgress, CancellationToken.None).ConfigureAwait(false);
}
@ -779,7 +764,7 @@ namespace MediaBrowser.Server.Implementations.Session
if (positionTicks.HasValue)
{
playedToCompletion = UpdatePlayState(item, data, positionTicks.Value);
playedToCompletion = _userDataRepository.UpdatePlayState(item, data, positionTicks.Value);
}
else
{
@ -795,65 +780,6 @@ namespace MediaBrowser.Server.Implementations.Session
return playedToCompletion;
}
/// <summary>
/// Updates playstate position for an item but does not save
/// </summary>
/// <param name="item">The item</param>
/// <param name="data">User data for the item</param>
/// <param name="positionTicks">The current playback position</param>
private bool UpdatePlayState(BaseItem item, UserItemData data, long positionTicks)
{
var playedToCompletion = false;
var hasRuntime = item.RunTimeTicks.HasValue && item.RunTimeTicks > 0;
// If a position has been reported, and if we know the duration
if (positionTicks > 0 && hasRuntime)
{
var pctIn = Decimal.Divide(positionTicks, item.RunTimeTicks.Value) * 100;
// Don't track in very beginning
if (pctIn < _configurationManager.Configuration.MinResumePct)
{
positionTicks = 0;
}
// If we're at the end, assume completed
else if (pctIn > _configurationManager.Configuration.MaxResumePct || positionTicks >= item.RunTimeTicks.Value)
{
positionTicks = 0;
data.Played = playedToCompletion = true;
}
else
{
// Enforce MinResumeDuration
var durationSeconds = TimeSpan.FromTicks(item.RunTimeTicks.Value).TotalSeconds;
if (durationSeconds < _configurationManager.Configuration.MinResumeDurationSeconds)
{
positionTicks = 0;
data.Played = playedToCompletion = true;
}
}
}
else if (!hasRuntime)
{
// If we don't know the runtime we'll just have to assume it was fully played
data.Played = playedToCompletion = true;
positionTicks = 0;
}
if (item is Audio)
{
positionTicks = 0;
}
data.PlaybackPositionTicks = positionTicks;
return playedToCompletion;
}
/// <summary>
/// Gets the session.
/// </summary>

View File

@ -358,6 +358,9 @@ namespace MediaBrowser.Server.Implementations.Sync
var streamInfo = new StreamBuilder().BuildVideoItem(options);
var mediaSource = streamInfo.MediaSource;
jobItem.MediaSourceId = streamInfo.MediaSourceId;
await _syncRepo.Update(jobItem).ConfigureAwait(false);
if (streamInfo.PlayMethod != PlayMethod.Transcode)
{
if (mediaSource.Protocol == MediaProtocol.File)
@ -389,6 +392,9 @@ namespace MediaBrowser.Server.Implementations.Sync
var streamInfo = new StreamBuilder().BuildAudioItem(options);
var mediaSource = streamInfo.MediaSource;
jobItem.MediaSourceId = streamInfo.MediaSourceId;
await _syncRepo.Update(jobItem).ConfigureAwait(false);
if (streamInfo.PlayMethod != PlayMethod.Transcode)
{
if (mediaSource.Protocol == MediaProtocol.File)

View File

@ -1,5 +1,9 @@
using MediaBrowser.Common.Extensions;
using System.IO;
using MediaBrowser.Common;
using MediaBrowser.Common.Extensions;
using MediaBrowser.Controller.Channels;
using MediaBrowser.Controller.Drawing;
using MediaBrowser.Controller.Dto;
using MediaBrowser.Controller.Entities;
using MediaBrowser.Controller.Entities.Audio;
using MediaBrowser.Controller.Entities.TV;
@ -7,10 +11,12 @@ using MediaBrowser.Controller.Library;
using MediaBrowser.Controller.LiveTv;
using MediaBrowser.Controller.Sync;
using MediaBrowser.Model.Dlna;
using MediaBrowser.Model.Dto;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Logging;
using MediaBrowser.Model.Querying;
using MediaBrowser.Model.Sync;
using MediaBrowser.Model.Users;
using MoreLinq;
using System;
using System.Collections.Generic;
@ -26,16 +32,20 @@ namespace MediaBrowser.Server.Implementations.Sync
private readonly IImageProcessor _imageProcessor;
private readonly ILogger _logger;
private readonly IUserManager _userManager;
private readonly IDtoService _dtoService;
private readonly IApplicationHost _appHost;
private ISyncProvider[] _providers = { };
public SyncManager(ILibraryManager libraryManager, ISyncRepository repo, IImageProcessor imageProcessor, ILogger logger, IUserManager userManager)
public SyncManager(ILibraryManager libraryManager, ISyncRepository repo, IImageProcessor imageProcessor, ILogger logger, IUserManager userManager, IDtoService dtoService, IApplicationHost appHost)
{
_libraryManager = libraryManager;
_repo = repo;
_imageProcessor = imageProcessor;
_logger = logger;
_userManager = userManager;
_dtoService = dtoService;
_appHost = appHost;
}
public void AddParts(IEnumerable<ISyncProvider> providers)
@ -251,6 +261,11 @@ namespace MediaBrowser.Server.Implementations.Sync
}
}
if (item is LiveTvChannel || item is IChannelItem || item is ILiveTvRecording)
{
return false;
}
return true;
}
@ -301,5 +316,54 @@ namespace MediaBrowser.Server.Implementations.Sync
{
return _repo.GetJobItems(query);
}
public SyncedItem GetJobItemInfo(string id)
{
var jobItem = GetJobItem(id);
var job = _repo.GetJob(jobItem.JobId);
var libraryItem = _libraryManager.GetItemById(jobItem.ItemId);
var syncedItem = new SyncedItem
{
SyncJobId = jobItem.JobId,
SyncJobItemId = jobItem.Id,
ServerId = _appHost.SystemId,
UserId = job.UserId
};
// Get everything
var fields = Enum.GetNames(typeof(ItemFields)).Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true)).ToList();
syncedItem.Item = _dtoService.GetBaseItemDto(libraryItem, new DtoOptions
{
Fields = fields
});
// TODO: this should be the media source of the transcoded output
syncedItem.Item.MediaSources = syncedItem.Item.MediaSources
.Where(i => string.Equals(i.Id, jobItem.MediaSourceId))
.ToList();
var mediaSource = syncedItem.Item.MediaSources
.FirstOrDefault(i => string.Equals(i.Id, jobItem.MediaSourceId));
// This will be null for items that are not audio/video
if (mediaSource == null)
{
syncedItem.OriginalFileName = Path.GetFileName(libraryItem.Path);
}
else
{
syncedItem.OriginalFileName = Path.GetFileName(mediaSource.Path);
}
return syncedItem;
}
public Task ReportOfflineAction(UserAction action)
{
return Task.FromResult(true);
}
}
}

View File

@ -36,7 +36,7 @@ namespace MediaBrowser.Server.Implementations.Sync
public async Task Initialize()
{
var dbFile = Path.Combine(_appPaths.DataPath, "sync6.db");
var dbFile = Path.Combine(_appPaths.DataPath, "sync7.db");
_connection = await SqliteExtensions.ConnectToDb(dbFile, _logger).ConfigureAwait(false);
@ -45,7 +45,7 @@ namespace MediaBrowser.Server.Implementations.Sync
"create table if not exists SyncJobs (Id GUID PRIMARY KEY, TargetId TEXT NOT NULL, Name TEXT NOT NULL, Quality TEXT NOT NULL, Status TEXT NOT NULL, Progress FLOAT, UserId TEXT NOT NULL, ItemIds TEXT NOT NULL, Category TEXT, ParentId TEXT, UnwatchedOnly BIT, ItemLimit INT, SyncNewContent BIT, DateCreated DateTime, DateLastModified DateTime, ItemCount int)",
"create index if not exists idx_SyncJobs on SyncJobs(Id)",
"create table if not exists SyncJobItems (Id GUID PRIMARY KEY, ItemId TEXT, JobId TEXT, OutputPath TEXT, Status TEXT, TargetId TEXT, DateCreated DateTime, Progress FLOAT)",
"create table if not exists SyncJobItems (Id GUID PRIMARY KEY, ItemId TEXT, MediaSourceId TEXT, JobId TEXT, OutputPath TEXT, Status TEXT, TargetId TEXT, DateCreated DateTime, Progress FLOAT)",
"create index if not exists idx_SyncJobItems on SyncJobs(Id)",
//pragmas
@ -90,10 +90,11 @@ namespace MediaBrowser.Server.Implementations.Sync
_saveJobCommand.Parameters.Add(_saveJobCommand, "@ItemCount");
_saveJobItemCommand = _connection.CreateCommand();
_saveJobItemCommand.CommandText = "replace into SyncJobItems (Id, ItemId, JobId, OutputPath, Status, TargetId, DateCreated, Progress) values (@Id, @ItemId, @JobId, @OutputPath, @Status, @TargetId, @DateCreated, @Progress)";
_saveJobItemCommand.CommandText = "replace into SyncJobItems (Id, ItemId, MediaSourceId, JobId, OutputPath, Status, TargetId, DateCreated, Progress) values (@Id, @ItemId, @MediaSourceId, @JobId, @OutputPath, @Status, @TargetId, @DateCreated, @Progress)";
_saveJobItemCommand.Parameters.Add(_saveJobCommand, "@Id");
_saveJobItemCommand.Parameters.Add(_saveJobCommand, "@ItemId");
_saveJobItemCommand.Parameters.Add(_saveJobCommand, "@MediaSourceId");
_saveJobItemCommand.Parameters.Add(_saveJobCommand, "@JobId");
_saveJobItemCommand.Parameters.Add(_saveJobCommand, "@OutputPath");
_saveJobItemCommand.Parameters.Add(_saveJobCommand, "@Status");
@ -103,7 +104,7 @@ namespace MediaBrowser.Server.Implementations.Sync
}
private const string BaseJobSelectText = "select Id, TargetId, Name, Quality, Status, Progress, UserId, ItemIds, Category, ParentId, UnwatchedOnly, ItemLimit, SyncNewContent, DateCreated, DateLastModified, ItemCount from SyncJobs";
private const string BaseJobItemSelectText = "select Id, ItemId, JobId, OutputPath, Status, TargetId, DateCreated, Progress from SyncJobItems";
private const string BaseJobItemSelectText = "select Id, ItemId, MediaSourceId, JobId, OutputPath, Status, TargetId, DateCreated, Progress from SyncJobItems";
public SyncJob GetJob(string id)
{
@ -556,6 +557,7 @@ namespace MediaBrowser.Server.Implementations.Sync
_saveJobItemCommand.GetParameter(index++).Value = new Guid(jobItem.Id);
_saveJobItemCommand.GetParameter(index++).Value = jobItem.ItemId;
_saveJobItemCommand.GetParameter(index++).Value = jobItem.MediaSourceId;
_saveJobItemCommand.GetParameter(index++).Value = jobItem.JobId;
_saveJobItemCommand.GetParameter(index++).Value = jobItem.OutputPath;
_saveJobItemCommand.GetParameter(index++).Value = jobItem.Status;
@ -606,26 +608,27 @@ namespace MediaBrowser.Server.Implementations.Sync
{
Id = reader.GetGuid(0).ToString("N"),
ItemId = reader.GetString(1),
JobId = reader.GetString(2)
MediaSourceId = reader.GetString(2),
JobId = reader.GetString(3)
};
if (!reader.IsDBNull(3))
{
info.OutputPath = reader.GetString(3);
}
if (!reader.IsDBNull(4))
{
info.Status = (SyncJobItemStatus)Enum.Parse(typeof(SyncJobItemStatus), reader.GetString(4), true);
info.OutputPath = reader.GetString(4);
}
info.TargetId = reader.GetString(5);
info.DateCreated = reader.GetDateTime(6);
if (!reader.IsDBNull(7))
if (!reader.IsDBNull(5))
{
info.Progress = reader.GetDouble(7);
info.Status = (SyncJobItemStatus)Enum.Parse(typeof(SyncJobItemStatus), reader.GetString(5), true);
}
info.TargetId = reader.GetString(6);
info.DateCreated = reader.GetDateTime(7);
if (!reader.IsDBNull(8))
{
info.Progress = reader.GetDouble(8);
}
return info;

View File

@ -410,7 +410,7 @@ namespace MediaBrowser.Server.Startup.Common
RegisterSingleInstance<IBlurayExaminer>(() => new BdInfoExaminer());
UserDataManager = new UserDataManager(LogManager);
UserDataManager = new UserDataManager(LogManager, ServerConfigurationManager);
RegisterSingleInstance(UserDataManager);
UserRepository = await GetUserRepository().ConfigureAwait(false);
@ -470,7 +470,7 @@ namespace MediaBrowser.Server.Startup.Common
ImageProcessor = new ImageProcessor(LogManager.GetLogger("ImageProcessor"), ServerConfigurationManager.ApplicationPaths, FileSystemManager, JsonSerializer, MediaEncoder);
RegisterSingleInstance(ImageProcessor);
SyncManager = new SyncManager(LibraryManager, SyncRepository, ImageProcessor, LogManager.GetLogger("SyncManager"), UserManager);
SyncManager = new SyncManager(LibraryManager, SyncRepository, ImageProcessor, LogManager.GetLogger("SyncManager"), UserManager, DtoService, this);
RegisterSingleInstance(SyncManager);
DtoService = new DtoService(Logger, LibraryManager, UserDataManager, ItemRepository, ImageProcessor, ServerConfigurationManager, FileSystemManager, ProviderManager, () => ChannelManager, SyncManager, this);
@ -485,7 +485,7 @@ namespace MediaBrowser.Server.Startup.Common
DeviceManager = new DeviceManager(new DeviceRepository(ApplicationPaths, JsonSerializer, Logger), UserManager, FileSystemManager, LibraryMonitor, ConfigurationManager, LogManager.GetLogger("DeviceManager"));
RegisterSingleInstance(DeviceManager);
SessionManager = new SessionManager(UserDataManager, ServerConfigurationManager, Logger, UserRepository, LibraryManager, UserManager, musicManager, DtoService, ImageProcessor, ItemRepository, JsonSerializer, this, HttpClient, AuthenticationRepository, DeviceManager);
SessionManager = new SessionManager(UserDataManager, Logger, UserRepository, LibraryManager, UserManager, musicManager, DtoService, ImageProcessor, ItemRepository, JsonSerializer, this, HttpClient, AuthenticationRepository, DeviceManager);
RegisterSingleInstance(SessionManager);
var newsService = new Implementations.News.NewsService(ApplicationPaths, JsonSerializer);

View File

@ -8,6 +8,7 @@ using MediaBrowser.Controller.Localization;
using MediaBrowser.Controller.Net;
using MediaBrowser.Controller.Plugins;
using MediaBrowser.Model.Logging;
using MediaBrowser.Model.Net;
using MediaBrowser.Model.Serialization;
using ServiceStack;
using ServiceStack.Web;

View File

@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>MediaBrowser.Common.Internal</id>
<version>3.0.523</version>
<version>3.0.530</version>
<title>MediaBrowser.Common.Internal</title>
<authors>Luke</authors>
<owners>ebr,Luke,scottisafool</owners>
@ -12,7 +12,7 @@
<description>Contains common components shared by Media Browser Theater and Media Browser Server. Not intended for plugin developer consumption.</description>
<copyright>Copyright © Media Browser 2013</copyright>
<dependencies>
<dependency id="MediaBrowser.Common" version="3.0.523" />
<dependency id="MediaBrowser.Common" version="3.0.530" />
<dependency id="NLog" version="3.1.0.0" />
<dependency id="SimpleInjector" version="2.6.1" />
<dependency id="sharpcompress" version="0.10.2" />

View File

@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>MediaBrowser.Common</id>
<version>3.0.523</version>
<version>3.0.530</version>
<title>MediaBrowser.Common</title>
<authors>Media Browser Team</authors>
<owners>ebr,Luke,scottisafool</owners>

View File

@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2011/08/nuspec.xsd">
<metadata>
<id>MediaBrowser.Model.Signed</id>
<version>3.0.523</version>
<version>3.0.530</version>
<title>MediaBrowser.Model - Signed Edition</title>
<authors>Media Browser Team</authors>
<owners>ebr,Luke,scottisafool</owners>

View File

@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>MediaBrowser.Server.Core</id>
<version>3.0.523</version>
<version>3.0.530</version>
<title>Media Browser.Server.Core</title>
<authors>Media Browser Team</authors>
<owners>ebr,Luke,scottisafool</owners>
@ -12,7 +12,7 @@
<description>Contains core components required to build plugins for Media Browser Server.</description>
<copyright>Copyright © Media Browser 2013</copyright>
<dependencies>
<dependency id="MediaBrowser.Common" version="3.0.523" />
<dependency id="MediaBrowser.Common" version="3.0.530" />
</dependencies>
</metadata>
<files>