2
0
Эх сурвалжийг харах

Merge pull request #2950 from MediaBrowser/dev

Dev
Luke 7 жил өмнө
parent
commit
526dea4f6f

+ 1 - 1
Emby.Drawing.ImageMagick/ImageMagickEncoder.cs

@@ -149,7 +149,7 @@ namespace Emby.Drawing.ImageMagick
 
 
                     var originalImageSize = new ImageSize(originalImage.CurrentImage.Width, originalImage.CurrentImage.Height);
                     var originalImageSize = new ImageSize(originalImage.CurrentImage.Width, originalImage.CurrentImage.Height);
 
 
-                    if (!options.CropWhiteSpace && options.HasDefaultOptions(inputPath, originalImageSize))
+                    if (!options.CropWhiteSpace && options.HasDefaultOptions(inputPath, originalImageSize) && !autoOrient)
                     {
                     {
                         // Just spit out the original file if all the options are default
                         // Just spit out the original file if all the options are default
                         return inputPath;
                         return inputPath;

+ 24 - 42
Emby.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHttpStream.cs

@@ -33,7 +33,7 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
             OriginalStreamId = originalStreamId;
             OriginalStreamId = originalStreamId;
         }
         }
 
 
-        protected override  Task OpenInternal(CancellationToken openCancellationToken)
+        protected override Task OpenInternal(CancellationToken openCancellationToken)
         {
         {
             _liveStreamCancellationTokenSource.Token.ThrowIfCancellationRequested();
             _liveStreamCancellationTokenSource.Token.ThrowIfCancellationRequested();
 
 
@@ -77,56 +77,38 @@ namespace Emby.Server.Implementations.LiveTv.TunerHosts.HdHomerun
         {
         {
             return Task.Run(async () =>
             return Task.Run(async () =>
             {
             {
-                var isFirstAttempt = true;
-
-                while (!cancellationToken.IsCancellationRequested)
+                try
                 {
                 {
-                    try
+                    using (var response = await _httpClient.SendAsync(new HttpRequestOptions
                     {
                     {
-                        using (var response = await _httpClient.SendAsync(new HttpRequestOptions
-                        {
-                            Url = url,
-                            CancellationToken = cancellationToken,
-                            BufferContent = false,
+                        Url = url,
+                        CancellationToken = cancellationToken,
+                        BufferContent = false,
 
 
-                            // Increase a little bit
-                            TimeoutMs = 30000,
+                        // Increase a little bit
+                        TimeoutMs = 30000,
 
 
-                            EnableHttpCompression = false
+                        EnableHttpCompression = false
 
 
-                        }, "GET").ConfigureAwait(false))
-                        {
-                            Logger.Info("Opened HDHR stream from {0}", url);
-
-                            if (!cancellationToken.IsCancellationRequested)
-                            {
-                                Logger.Info("Beginning multicastStream.CopyUntilCancelled");
-
-                                FileSystem.CreateDirectory(FileSystem.GetDirectoryName(TempFilePath));
-                                using (var fileStream = FileSystem.GetFileStream(TempFilePath, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read, FileOpenOptions.None))
-                                {
-                                    StreamHelper.CopyTo(response.Content, fileStream, 81920, () => Resolve(openTaskCompletionSource), cancellationToken);
-                                }
-                            }
-                        }
-                    }
-                    catch (OperationCanceledException)
-                    {
-                        break;
-                    }
-                    catch (Exception ex)
+                    }, "GET").ConfigureAwait(false))
                     {
                     {
-                        if (isFirstAttempt)
+                        Logger.Info("Opened HDHR stream from {0}", url);
+
+                        Logger.Info("Beginning multicastStream.CopyUntilCancelled");
+
+                        FileSystem.CreateDirectory(FileSystem.GetDirectoryName(TempFilePath));
+                        using (var fileStream = FileSystem.GetFileStream(TempFilePath, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read, FileOpenOptions.None))
                         {
                         {
-                            Logger.ErrorException("Error opening live stream:", ex);
-                            openTaskCompletionSource.TrySetException(ex);
-                            break;
+                            StreamHelper.CopyTo(response.Content, fileStream, 81920, () => Resolve(openTaskCompletionSource), cancellationToken);
                         }
                         }
-
-                        Logger.ErrorException("Error copying live stream, will reopen", ex);
                     }
                     }
-
-                    isFirstAttempt = false;
+                }
+                catch (OperationCanceledException)
+                {
+                }
+                catch (Exception ex)
+                {
+                    Logger.ErrorException("Error copying live stream.", ex);
                 }
                 }
 
 
                 _liveStreamTaskCompletionSource.TrySetResult(true);
                 _liveStreamTaskCompletionSource.TrySetResult(true);

+ 76 - 5
Emby.Server.Implementations/Networking/NetworkManager.cs

@@ -81,8 +81,18 @@ namespace Emby.Server.Implementations.Networking
                 return true;
                 return true;
             }
             }
 
 
-            // Handle ipv4 mapped to ipv6
-            endpoint = endpoint.Replace("::ffff:", string.Empty);
+            // ipv6
+            if (endpoint.Split('.').Length > 4)
+            {
+                // Handle ipv4 mapped to ipv6
+                var originalEndpoint = endpoint;
+                endpoint = endpoint.Replace("::ffff:", string.Empty);
+
+                if (string.Equals(endpoint, originalEndpoint, StringComparison.OrdinalIgnoreCase))
+                {
+                    return false;
+                }
+            }
 
 
             // Private address space:
             // Private address space:
             // http://en.wikipedia.org/wiki/Private_network
             // http://en.wikipedia.org/wiki/Private_network
@@ -92,13 +102,74 @@ namespace Emby.Server.Implementations.Networking
                 return Is172AddressPrivate(endpoint);
                 return Is172AddressPrivate(endpoint);
             }
             }
 
 
-            return
+            return endpoint.StartsWith("localhost", StringComparison.OrdinalIgnoreCase) ||
+                endpoint.StartsWith("127.0.0.1", StringComparison.OrdinalIgnoreCase) ||
+                IsInPrivateAddressSpaceAndLocalSubnet(endpoint);
+        }
+
+        public bool IsInPrivateAddressSpaceAndLocalSubnet(string endpoint)
+        {
+            var endpointFirstPart = endpoint.Split('.')[0];
 
 
-                endpoint.StartsWith("localhost", StringComparison.OrdinalIgnoreCase) ||
+            string subnet_Match = "";
+            if (
                 endpoint.StartsWith("127.", StringComparison.OrdinalIgnoreCase) ||
                 endpoint.StartsWith("127.", StringComparison.OrdinalIgnoreCase) ||
                 endpoint.StartsWith("10.", StringComparison.OrdinalIgnoreCase) ||
                 endpoint.StartsWith("10.", StringComparison.OrdinalIgnoreCase) ||
                 endpoint.StartsWith("192.168", StringComparison.OrdinalIgnoreCase) ||
                 endpoint.StartsWith("192.168", StringComparison.OrdinalIgnoreCase) ||
-                endpoint.StartsWith("169.", StringComparison.OrdinalIgnoreCase);
+                endpoint.StartsWith("169.", StringComparison.OrdinalIgnoreCase)
+                )
+            {
+                foreach (NetworkInterface adapter in NetworkInterface.GetAllNetworkInterfaces())
+                    foreach (UnicastIPAddressInformation unicastIPAddressInformation in adapter.GetIPProperties().UnicastAddresses)
+                        if (unicastIPAddressInformation.Address.AddressFamily == AddressFamily.InterNetwork && endpointFirstPart == unicastIPAddressInformation.Address.ToString().Split('.')[0])
+                        {
+                            int subnet_Test = 0;
+                            foreach (string part in unicastIPAddressInformation.IPv4Mask.ToString().Split('.'))
+                            {
+                                if (part.Equals("0")) break;
+                                subnet_Test++;
+                            }
+
+                            subnet_Match = String.Join(".", unicastIPAddressInformation.Address.ToString().Split('.').Take(subnet_Test).ToArray());
+                        }
+            }
+
+            return endpoint.StartsWith(subnet_Match + ".", StringComparison.OrdinalIgnoreCase);
+        }
+
+        private Dictionary<string, string> _subnetLookup = new Dictionary<string, string>(StringComparer.Ordinal);
+        private string GetSubnet(string endpointFirstPart)
+        {
+            string subnet_Match = "";
+
+            lock (_subnetLookup)
+            {
+                if (_subnetLookup.TryGetValue(endpointFirstPart, out subnet_Match))
+                {
+                    return subnet_Match;
+                }
+
+                foreach (NetworkInterface adapter in NetworkInterface.GetAllNetworkInterfaces())
+                    foreach (UnicastIPAddressInformation unicastIPAddressInformation in adapter.GetIPProperties().UnicastAddresses)
+                        if (unicastIPAddressInformation.Address.AddressFamily == AddressFamily.InterNetwork && endpointFirstPart == unicastIPAddressInformation.Address.ToString().Split('.')[0])
+                        {
+                            int subnet_Test = 0;
+                            foreach (string part in unicastIPAddressInformation.IPv4Mask.ToString().Split('.'))
+                            {
+                                if (part.Equals("0")) break;
+                                subnet_Test++;
+                            }
+
+                            subnet_Match = String.Join(".", unicastIPAddressInformation.Address.ToString().Split('.').Take(subnet_Test).ToArray());
+                        }
+
+                if (!string.IsNullOrWhiteSpace(subnet_Match))
+                {
+                    _subnetLookup[endpointFirstPart] = subnet_Match;
+                }
+            }
+
+            return subnet_Match;
         }
         }
 
 
         private bool Is172AddressPrivate(string endpoint)
         private bool Is172AddressPrivate(string endpoint)

+ 1 - 1
MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs

@@ -1638,7 +1638,7 @@ namespace MediaBrowser.Controller.MediaEncoding
 
 
             if (state.InputProtocol == MediaProtocol.Rtsp)
             if (state.InputProtocol == MediaProtocol.Rtsp)
             {
             {
-                inputModifier += " -rtsp_transport tcp";
+                inputModifier += " -rtsp_transport tcp -rtsp_transport udp -rtsp_flags prefer_tcp";
             }
             }
 
 
             if (!string.IsNullOrEmpty(state.InputAudioSync))
             if (!string.IsNullOrEmpty(state.InputAudioSync))

+ 9 - 15
MediaBrowser.Providers/Manager/ItemImageProvider.cs

@@ -517,21 +517,11 @@ namespace MediaBrowser.Providers.Manager
                 return true;
                 return true;
             }
             }
 
 
-            if (libraryOptions.DownloadImagesInAdvance)
-            {
-                return false;
-            }
-
             if (item.LocationType == LocationType.Remote || item.LocationType == LocationType.Virtual)
             if (item.LocationType == LocationType.Remote || item.LocationType == LocationType.Virtual)
             {
             {
                 return true;
                 return true;
             }
             }
 
 
-            if (!item.IsSaveLocalMetadataEnabled())
-            {
-                return true;
-            }
-
             if (item is IItemByName && !(item is MusicArtist))
             if (item is IItemByName && !(item is MusicArtist))
             {
             {
                 var hasDualAccess = item as IHasDualAccess;
                 var hasDualAccess = item as IHasDualAccess;
@@ -541,13 +531,17 @@ namespace MediaBrowser.Providers.Manager
                 }
                 }
             }
             }
 
 
-            switch (type)
+            if (libraryOptions.DownloadImagesInAdvance)
             {
             {
-                case ImageType.Primary:
-                    return true;
-                default:
-                    return true;
+                return false;
             }
             }
+
+            //if (!item.IsSaveLocalMetadataEnabled())
+            //{
+            //    return true;
+            //}
+
+            return true;
         }
         }
 
 
         private void SaveImageStub(IHasMetadata item, ImageType imageType, IEnumerable<string> urls)
         private void SaveImageStub(IHasMetadata item, ImageType imageType, IEnumerable<string> urls)

+ 1 - 1
SharedVersion.cs

@@ -1,3 +1,3 @@
 using System.Reflection;
 using System.Reflection;
 
 
-[assembly: AssemblyVersion("3.2.33.5")]
+[assembly: AssemblyVersion("3.2.33.6")]