diff options
Diffstat (limited to 'MediaBrowser.Controller')
| -rw-r--r-- | MediaBrowser.Controller/Channels/ChannelMediaInfo.cs | 70 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Connect/ConnectUser.cs | 18 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Connect/IConnectManager.cs | 27 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Devices/IDeviceManager.cs | 17 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Entities/BaseItem.cs | 23 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Entities/ItemImageInfo.cs | 4 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Entities/User.cs | 39 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Entities/Video.cs | 24 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Library/IUserManager.cs | 6 | ||||
| -rw-r--r-- | MediaBrowser.Controller/LiveTv/ILiveTvManager.cs | 7 | ||||
| -rw-r--r-- | MediaBrowser.Controller/LiveTv/ILiveTvService.cs | 5 | ||||
| -rw-r--r-- | MediaBrowser.Controller/LiveTv/LiveStreamInfo.cs | 43 | ||||
| -rw-r--r-- | MediaBrowser.Controller/MediaBrowser.Controller.csproj | 2 | ||||
| -rw-r--r-- | MediaBrowser.Controller/Resolvers/BaseVideoResolver.cs | 13 |
14 files changed, 197 insertions, 101 deletions
diff --git a/MediaBrowser.Controller/Channels/ChannelMediaInfo.cs b/MediaBrowser.Controller/Channels/ChannelMediaInfo.cs index f16fd1120..64a4f355c 100644 --- a/MediaBrowser.Controller/Channels/ChannelMediaInfo.cs +++ b/MediaBrowser.Controller/Channels/ChannelMediaInfo.cs @@ -1,6 +1,10 @@ -using MediaBrowser.Model.MediaInfo; +using MediaBrowser.Common.Extensions; +using MediaBrowser.Model.Dto; +using MediaBrowser.Model.Entities; +using MediaBrowser.Model.MediaInfo; using System; using System.Collections.Generic; +using System.Linq; namespace MediaBrowser.Controller.Channels { @@ -31,6 +35,8 @@ namespace MediaBrowser.Controller.Channels public long? RunTimeTicks { get; set; } + public string Id { get; set; } + public ChannelMediaInfo() { RequiredHttpHeaders = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); @@ -38,5 +44,67 @@ namespace MediaBrowser.Controller.Channels // This is most common Protocol = MediaProtocol.Http; } + + public MediaSourceInfo ToMediaSource() + { + var id = Path.GetMD5().ToString("N"); + + var source = new MediaSourceInfo + { + MediaStreams = GetMediaStreams(this).ToList(), + + Container = Container, + Protocol = Protocol, + Path = Path, + RequiredHttpHeaders = RequiredHttpHeaders, + RunTimeTicks = RunTimeTicks, + Name = id, + Id = id + }; + + var bitrate = (AudioBitrate ?? 0) + (VideoBitrate ?? 0); + + if (bitrate > 0) + { + source.Bitrate = bitrate; + } + + return source; + } + + private IEnumerable<MediaStream> GetMediaStreams(ChannelMediaInfo info) + { + var list = new List<MediaStream>(); + + if (!string.IsNullOrWhiteSpace(info.VideoCodec) && + !string.IsNullOrWhiteSpace(info.AudioCodec)) + { + list.Add(new MediaStream + { + Type = MediaStreamType.Video, + Width = info.Width, + RealFrameRate = info.Framerate, + Profile = info.VideoProfile, + Level = info.VideoLevel, + Index = -1, + Height = info.Height, + Codec = info.VideoCodec, + BitRate = info.VideoBitrate, + AverageFrameRate = info.Framerate + }); + + list.Add(new MediaStream + { + Type = MediaStreamType.Audio, + Index = -1, + Codec = info.AudioCodec, + BitRate = info.AudioBitrate, + Channels = info.AudioChannels, + SampleRate = info.AudioSampleRate + }); + } + + return list; + } } }
\ No newline at end of file diff --git a/MediaBrowser.Controller/Connect/ConnectUser.cs b/MediaBrowser.Controller/Connect/ConnectUser.cs deleted file mode 100644 index 389330cec..000000000 --- a/MediaBrowser.Controller/Connect/ConnectUser.cs +++ /dev/null @@ -1,18 +0,0 @@ - -namespace MediaBrowser.Controller.Connect -{ - public class ConnectUser - { - public string Id { get; set; } - public string Name { get; set; } - public string Email { get; set; } - public bool IsActive { get; set; } - } - - public class ConnectUserQuery - { - public string Id { get; set; } - public string Name { get; set; } - public string Email { get; set; } - } -} diff --git a/MediaBrowser.Controller/Connect/IConnectManager.cs b/MediaBrowser.Controller/Connect/IConnectManager.cs index 7c1e14c30..8bd0332c0 100644 --- a/MediaBrowser.Controller/Connect/IConnectManager.cs +++ b/MediaBrowser.Controller/Connect/IConnectManager.cs @@ -1,4 +1,6 @@ -using System.Threading.Tasks; +using MediaBrowser.Model.Connect; +using System.Collections.Generic; +using System.Threading.Tasks; namespace MediaBrowser.Controller.Connect { @@ -23,6 +25,27 @@ namespace MediaBrowser.Controller.Connect /// </summary> /// <param name="userId">The user identifier.</param> /// <returns>Task.</returns> - Task RemoveLink(string userId); + Task RemoveConnect(string userId); + + /// <summary> + /// Invites the user. + /// </summary> + /// <param name="sendingUserId">The sending user identifier.</param> + /// <param name="connectUsername">The connect username.</param> + /// <returns>Task<UserLinkResult>.</returns> + Task<UserLinkResult> InviteUser(string sendingUserId, string connectUsername); + + /// <summary> + /// Gets the pending guests. + /// </summary> + /// <returns>Task<List<ConnectAuthorization>>.</returns> + Task<List<ConnectAuthorization>> GetPendingGuests(); + + /// <summary> + /// Cancels the authorization. + /// </summary> + /// <param name="id">The identifier.</param> + /// <returns>Task.</returns> + Task CancelAuthorization(string id); } } diff --git a/MediaBrowser.Controller/Devices/IDeviceManager.cs b/MediaBrowser.Controller/Devices/IDeviceManager.cs index e66de42bb..af184e6e9 100644 --- a/MediaBrowser.Controller/Devices/IDeviceManager.cs +++ b/MediaBrowser.Controller/Devices/IDeviceManager.cs @@ -1,5 +1,7 @@ using MediaBrowser.Model.Devices; +using MediaBrowser.Model.Events; using MediaBrowser.Model.Session; +using System; using System.Collections.Generic; using System.IO; using System.Threading.Tasks; @@ -9,6 +11,11 @@ namespace MediaBrowser.Controller.Devices public interface IDeviceManager { /// <summary> + /// Occurs when [device options updated]. + /// </summary> + event EventHandler<GenericEventArgs<DeviceInfo>> DeviceOptionsUpdated; + + /// <summary> /// Registers the device. /// </summary> /// <param name="reportedId">The reported identifier.</param> @@ -16,7 +23,7 @@ namespace MediaBrowser.Controller.Devices /// <param name="appName">Name of the application.</param> /// <param name="usedByUserId">The used by user identifier.</param> /// <returns>Task.</returns> - Task RegisterDevice(string reportedId, string name, string appName, string usedByUserId); + Task<DeviceInfo> RegisterDevice(string reportedId, string name, string appName, string usedByUserId); /// <summary> /// Saves the capabilities. @@ -41,6 +48,14 @@ namespace MediaBrowser.Controller.Devices DeviceInfo GetDevice(string id); /// <summary> + /// Updates the device information. + /// </summary> + /// <param name="id">The identifier.</param> + /// <param name="options">The options.</param> + /// <returns>Task.</returns> + Task UpdateDeviceInfo(string id, DeviceOptions options); + + /// <summary> /// Gets the devices. /// </summary> /// <returns>IEnumerable<DeviceInfo>.</returns> diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index d5296d7dc..0ecedcdda 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -564,6 +564,11 @@ namespace MediaBrowser.Controller.Entities return PlayAccess.None; } + //if (!user.IsParentalScheduleAllowed()) + //{ + // return PlayAccess.None; + //} + return PlayAccess.Full; } @@ -1465,8 +1470,6 @@ namespace MediaBrowser.Controller.Entities image.Path = file.FullName; image.DateModified = imageInfo.DateModified; - image.Width = imageInfo.Width; - image.Height = imageInfo.Height; } } @@ -1639,26 +1642,12 @@ namespace MediaBrowser.Controller.Entities private ItemImageInfo GetImageInfo(FileSystemInfo file, ImageType type) { - var info = new ItemImageInfo + return new ItemImageInfo { Path = file.FullName, Type = type, DateModified = FileSystem.GetLastWriteTimeUtc(file) }; - - try - { - var size = ImageProcessor.GetImageSize(info.Path); - - info.Width = Convert.ToInt32(size.Width); - info.Height = Convert.ToInt32(size.Height); - } - catch - { - - } - - return info; } /// <summary> diff --git a/MediaBrowser.Controller/Entities/ItemImageInfo.cs b/MediaBrowser.Controller/Entities/ItemImageInfo.cs index fe1f0598a..80aec6482 100644 --- a/MediaBrowser.Controller/Entities/ItemImageInfo.cs +++ b/MediaBrowser.Controller/Entities/ItemImageInfo.cs @@ -10,9 +10,5 @@ namespace MediaBrowser.Controller.Entities public ImageType Type { get; set; } public DateTime DateModified { get; set; } - - public int? Width { get; set; } - - public int? Height { get; set; } } } diff --git a/MediaBrowser.Controller/Entities/User.cs b/MediaBrowser.Controller/Entities/User.cs index e0682c9ee..6ba8701f7 100644 --- a/MediaBrowser.Controller/Entities/User.cs +++ b/MediaBrowser.Controller/Entities/User.cs @@ -6,6 +6,7 @@ using MediaBrowser.Model.Connect; using MediaBrowser.Model.Serialization; using System; using System.IO; +using System.Linq; using System.Runtime.Serialization; using System.Threading; using System.Threading.Tasks; @@ -35,7 +36,7 @@ namespace MediaBrowser.Controller.Entities public string ConnectUserName { get; set; } public string ConnectUserId { get; set; } - public UserLinkType ConnectLinkType { get; set; } + public UserLinkType? ConnectLinkType { get; set; } public string ConnectAccessKey { get; set; } /// <summary> @@ -259,5 +260,41 @@ namespace MediaBrowser.Controller.Entities Configuration = config; UserManager.UpdateConfiguration(this, Configuration); } + + public bool IsParentalScheduleAllowed() + { + return IsParentalScheduleAllowed(DateTime.UtcNow); + } + + public bool IsParentalScheduleAllowed(DateTime date) + { + var schedules = Configuration.AccessSchedules; + + if (schedules.Length == 0) + { + return true; + } + + return schedules.Any(i => IsParentalScheduleAllowed(i, date)); + } + + private bool IsParentalScheduleAllowed(AccessSchedule schedule, DateTime date) + { + if (date.Kind != DateTimeKind.Utc) + { + throw new ArgumentException("Utc date expected"); + } + + var localTime = date.ToLocalTime(); + + return localTime.DayOfWeek == schedule.DayOfWeek && IsWithinTime(schedule, localTime); + } + + private bool IsWithinTime(AccessSchedule schedule, DateTime localTime) + { + var hour = localTime.TimeOfDay.TotalHours; + + return hour >= schedule.StartHour && hour <= schedule.EndHour; + } } } diff --git a/MediaBrowser.Controller/Entities/Video.cs b/MediaBrowser.Controller/Entities/Video.cs index 59649de7f..f4104b29d 100644 --- a/MediaBrowser.Controller/Entities/Video.cs +++ b/MediaBrowser.Controller/Entities/Video.cs @@ -128,6 +128,8 @@ namespace MediaBrowser.Controller.Entities public bool HasSubtitles { get; set; } public bool IsPlaceHolder { get; set; } + public bool IsShortcut { get; set; } + public string ShortcutPath { get; set; } /// <summary> /// Gets or sets the tags. @@ -577,6 +579,28 @@ namespace MediaBrowser.Controller.Entities PlayableStreamFileNames = i.PlayableStreamFileNames.ToList() }; + if (i.IsShortcut) + { + info.Path = i.ShortcutPath; + + if (info.Path.StartsWith("Http", StringComparison.OrdinalIgnoreCase)) + { + info.Protocol = MediaProtocol.Http; + } + else if (info.Path.StartsWith("Rtmp", StringComparison.OrdinalIgnoreCase)) + { + info.Protocol = MediaProtocol.Rtmp; + } + else if (info.Path.StartsWith("Rtsp", StringComparison.OrdinalIgnoreCase)) + { + info.Protocol = MediaProtocol.Rtsp; + } + else + { + info.Protocol = MediaProtocol.File; + } + } + if (string.IsNullOrEmpty(info.Container)) { if (i.VideoType == VideoType.VideoFile || i.VideoType == VideoType.Iso) diff --git a/MediaBrowser.Controller/Library/IUserManager.cs b/MediaBrowser.Controller/Library/IUserManager.cs index 3efdbea76..39ec2b85d 100644 --- a/MediaBrowser.Controller/Library/IUserManager.cs +++ b/MediaBrowser.Controller/Library/IUserManager.cs @@ -55,16 +55,16 @@ namespace MediaBrowser.Controller.Library /// <param name="id">The identifier.</param> /// <returns>User.</returns> User GetUserById(string id); - + /// <summary> /// Authenticates a User and returns a result indicating whether or not it succeeded /// </summary> /// <param name="username">The username.</param> - /// <param name="password">The password.</param> + /// <param name="passwordSha1">The password sha1.</param> /// <param name="remoteEndPoint">The remote end point.</param> /// <returns>Task{System.Boolean}.</returns> /// <exception cref="System.ArgumentNullException">user</exception> - Task<bool> AuthenticateUser(string username, string password, string remoteEndPoint); + Task<bool> AuthenticateUser(string username, string passwordSha1, string remoteEndPoint); /// <summary> /// Refreshes metadata for each user diff --git a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs index 370ac2e75..fcd973ec2 100644 --- a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs +++ b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs @@ -1,4 +1,5 @@ -using MediaBrowser.Controller.Entities; +using MediaBrowser.Controller.Channels; +using MediaBrowser.Controller.Entities; using MediaBrowser.Model.Dto; using MediaBrowser.Model.LiveTv; using MediaBrowser.Model.Querying; @@ -154,7 +155,7 @@ namespace MediaBrowser.Controller.LiveTv /// <param name="id">The identifier.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns>Task{Stream}.</returns> - Task<LiveStreamInfo> GetRecordingStream(string id, CancellationToken cancellationToken); + Task<ChannelMediaInfo> GetRecordingStream(string id, CancellationToken cancellationToken); /// <summary> /// Gets the channel stream. @@ -162,7 +163,7 @@ namespace MediaBrowser.Controller.LiveTv /// <param name="id">The identifier.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns>Task{StreamResponseInfo}.</returns> - Task<LiveStreamInfo> GetChannelStream(string id, CancellationToken cancellationToken); + Task<ChannelMediaInfo> GetChannelStream(string id, CancellationToken cancellationToken); /// <summary> /// Gets the program. diff --git a/MediaBrowser.Controller/LiveTv/ILiveTvService.cs b/MediaBrowser.Controller/LiveTv/ILiveTvService.cs index 3abbe500f..eda69b164 100644 --- a/MediaBrowser.Controller/LiveTv/ILiveTvService.cs +++ b/MediaBrowser.Controller/LiveTv/ILiveTvService.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; +using MediaBrowser.Controller.Channels; namespace MediaBrowser.Controller.LiveTv { @@ -172,7 +173,7 @@ namespace MediaBrowser.Controller.LiveTv /// <param name="recordingId">The recording identifier.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns>Task{Stream}.</returns> - Task<LiveStreamInfo> GetRecordingStream(string recordingId, CancellationToken cancellationToken); + Task<ChannelMediaInfo> GetRecordingStream(string recordingId, CancellationToken cancellationToken); /// <summary> /// Gets the channel stream. @@ -180,7 +181,7 @@ namespace MediaBrowser.Controller.LiveTv /// <param name="channelId">The channel identifier.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns>Task{Stream}.</returns> - Task<LiveStreamInfo> GetChannelStream(string channelId, CancellationToken cancellationToken); + Task<ChannelMediaInfo> GetChannelStream(string channelId, CancellationToken cancellationToken); /// <summary> /// Closes the live stream. diff --git a/MediaBrowser.Controller/LiveTv/LiveStreamInfo.cs b/MediaBrowser.Controller/LiveTv/LiveStreamInfo.cs deleted file mode 100644 index 019c9d31a..000000000 --- a/MediaBrowser.Controller/LiveTv/LiveStreamInfo.cs +++ /dev/null @@ -1,43 +0,0 @@ -using MediaBrowser.Model.Entities; -using System.Collections.Generic; - -namespace MediaBrowser.Controller.LiveTv -{ - public class LiveStreamInfo - { - /// <summary> - /// Gets or sets the path. - /// </summary> - /// <value>The path.</value> - public string Path { get; set; } - - /// <summary> - /// Gets or sets the URL. - /// </summary> - /// <value>The URL.</value> - public string Url { get; set; } - - /// <summary> - /// Gets or sets the identifier. - /// </summary> - /// <value>The identifier.</value> - public string Id { get; set; } - - /// <summary> - /// Gets or sets the media container. - /// </summary> - /// <value>The media container.</value> - public string MediaContainer { get; set; } - - /// <summary> - /// Gets or sets the media streams. - /// </summary> - /// <value>The media streams.</value> - public List<MediaStream> MediaStreams { get; set; } - - public LiveStreamInfo() - { - MediaStreams = new List<MediaStream>(); - } - } -} diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj index a49d00e87..7039a00eb 100644 --- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj +++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj @@ -99,7 +99,6 @@ <Compile Include="Collections\CollectionCreationOptions.cs" /> <Compile Include="Collections\CollectionEvents.cs" /> <Compile Include="Collections\ICollectionManager.cs" /> - <Compile Include="Connect\ConnectUser.cs" /> <Compile Include="Connect\IConnectManager.cs" /> <Compile Include="Connect\UserLinkResult.cs" /> <Compile Include="Devices\IDeviceManager.cs" /> @@ -182,7 +181,6 @@ <Compile Include="LiveTv\RecordingGroup.cs" /> <Compile Include="LiveTv\RecordingStatusChangedEventArgs.cs" /> <Compile Include="LiveTv\ILiveTvRecording.cs" /> - <Compile Include="LiveTv\LiveStreamInfo.cs" /> <Compile Include="LiveTv\LiveTvAudioRecording.cs" /> <Compile Include="LiveTv\LiveTvChannel.cs" /> <Compile Include="LiveTv\ChannelInfo.cs" /> diff --git a/MediaBrowser.Controller/Resolvers/BaseVideoResolver.cs b/MediaBrowser.Controller/Resolvers/BaseVideoResolver.cs index 038d8d48b..5725c6482 100644 --- a/MediaBrowser.Controller/Resolvers/BaseVideoResolver.cs +++ b/MediaBrowser.Controller/Resolvers/BaseVideoResolver.cs @@ -38,19 +38,24 @@ namespace MediaBrowser.Controller.Resolvers // http://wiki.xbmc.org/index.php?title=Media_stubs var isPlaceHolder = EntityResolutionHelper.IsVideoPlaceHolder(args.Path); - if (EntityResolutionHelper.IsVideoFile(args.Path) || isPlaceHolder) - { - var extension = Path.GetExtension(args.Path); + var extension = Path.GetExtension(args.Path); + + var isShortcut = string.Equals(extension, ".strm", StringComparison.OrdinalIgnoreCase); + if (EntityResolutionHelper.IsVideoFile(args.Path) || isPlaceHolder || isShortcut) + { var type = string.Equals(extension, ".iso", StringComparison.OrdinalIgnoreCase) || string.Equals(extension, ".img", StringComparison.OrdinalIgnoreCase) ? VideoType.Iso : VideoType.VideoFile; + var path = args.Path; + var video = new TVideoType { VideoType = type, Path = args.Path, IsInMixedFolder = true, - IsPlaceHolder = isPlaceHolder + IsPlaceHolder = isPlaceHolder, + IsShortcut = isShortcut }; if (isPlaceHolder) |
