diff options
| author | Luke <luke.pulverenti@gmail.com> | 2017-02-01 15:57:05 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-02-01 15:57:05 -0500 |
| commit | 7ab5db614f6fdccdeac4b66a08d1a0ab34902792 (patch) | |
| tree | 8a0a31f41fe95618e687bacceb6ea6e81c4b4bd3 /MediaBrowser.Api | |
| parent | 8cef129580670dcf49855dd75e167baace3b609d (diff) | |
| parent | 39e8e3cbe7865ba618c67c612a191b134f5ad186 (diff) | |
Merge pull request #2436 from MediaBrowser/dev
Dev
Diffstat (limited to 'MediaBrowser.Api')
| -rw-r--r-- | MediaBrowser.Api/BasePeriodicWebSocketListener.cs | 29 | ||||
| -rw-r--r-- | MediaBrowser.Api/Playback/BaseStreamingService.cs | 29 | ||||
| -rw-r--r-- | MediaBrowser.Api/Playback/Hls/BaseHlsService.cs | 2 |
3 files changed, 26 insertions, 34 deletions
diff --git a/MediaBrowser.Api/BasePeriodicWebSocketListener.cs b/MediaBrowser.Api/BasePeriodicWebSocketListener.cs index fe7de387f8..8004d7e9bf 100644 --- a/MediaBrowser.Api/BasePeriodicWebSocketListener.cs +++ b/MediaBrowser.Api/BasePeriodicWebSocketListener.cs @@ -23,8 +23,8 @@ namespace MediaBrowser.Api /// <summary> /// The _active connections /// </summary> - protected readonly List<Tuple<IWebSocketConnection, CancellationTokenSource, ITimer, TStateType, SemaphoreSlim>> ActiveConnections = - new List<Tuple<IWebSocketConnection, CancellationTokenSource, ITimer, TStateType, SemaphoreSlim>>(); + protected readonly List<Tuple<IWebSocketConnection, CancellationTokenSource, ITimer, TStateType>> ActiveConnections = + new List<Tuple<IWebSocketConnection, CancellationTokenSource, ITimer, TStateType>>(); /// <summary> /// Gets the name. @@ -132,11 +132,9 @@ namespace MediaBrowser.Api InitialDelayMs = dueTimeMs }; - var semaphore = new SemaphoreSlim(1, 1); - lock (ActiveConnections) { - ActiveConnections.Add(new Tuple<IWebSocketConnection, CancellationTokenSource, ITimer, TStateType, SemaphoreSlim>(message.Connection, cancellationTokenSource, timer, state, semaphore)); + ActiveConnections.Add(new Tuple<IWebSocketConnection, CancellationTokenSource, ITimer, TStateType>(message.Connection, cancellationTokenSource, timer, state)); } if (timer != null) @@ -153,7 +151,7 @@ namespace MediaBrowser.Api { var connection = (IWebSocketConnection)state; - Tuple<IWebSocketConnection, CancellationTokenSource, ITimer, TStateType, SemaphoreSlim> tuple; + Tuple<IWebSocketConnection, CancellationTokenSource, ITimer, TStateType> tuple; lock (ActiveConnections) { @@ -176,7 +174,7 @@ namespace MediaBrowser.Api protected void SendData(bool force) { - List<Tuple<IWebSocketConnection, CancellationTokenSource, ITimer, TStateType, SemaphoreSlim>> tuples; + List<Tuple<IWebSocketConnection, CancellationTokenSource, ITimer, TStateType>> tuples; lock (ActiveConnections) { @@ -204,14 +202,12 @@ namespace MediaBrowser.Api } } - private async void SendData(Tuple<IWebSocketConnection, CancellationTokenSource, ITimer, TStateType, SemaphoreSlim> tuple) + private async void SendData(Tuple<IWebSocketConnection, CancellationTokenSource, ITimer, TStateType> tuple) { var connection = tuple.Item1; try { - await tuple.Item5.WaitAsync(tuple.Item2.Token).ConfigureAwait(false); - var state = tuple.Item4; var data = await GetDataToSend(state).ConfigureAwait(false); @@ -227,8 +223,6 @@ namespace MediaBrowser.Api state.DateLastSendUtc = DateTime.UtcNow; } - - tuple.Item5.Release(); } catch (OperationCanceledException) { @@ -265,7 +259,7 @@ namespace MediaBrowser.Api /// Disposes the connection. /// </summary> /// <param name="connection">The connection.</param> - private void DisposeConnection(Tuple<IWebSocketConnection, CancellationTokenSource, ITimer, TStateType, SemaphoreSlim> connection) + private void DisposeConnection(Tuple<IWebSocketConnection, CancellationTokenSource, ITimer, TStateType> connection) { Logger.Debug("{1} stop transmitting over websocket to {0}", connection.Item1.RemoteEndPoint, GetType().Name); @@ -293,15 +287,6 @@ namespace MediaBrowser.Api } - try - { - connection.Item5.Dispose(); - } - catch (ObjectDisposedException) - { - - } - ActiveConnections.Remove(connection); } diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs index 6a677abfc5..f5aa954ee1 100644 --- a/MediaBrowser.Api/Playback/BaseStreamingService.cs +++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs @@ -2720,6 +2720,15 @@ namespace MediaBrowser.Api.Playback //inputModifier += " -noaccurate_seek"; } + if (!string.IsNullOrWhiteSpace(state.InputContainer)) + { + var inputFormat = GetInputFormat(state.InputContainer); + if (!string.IsNullOrWhiteSpace(inputFormat)) + { + inputModifier += " -f " + inputFormat; + } + } + if (state.RunTimeTicks.HasValue) { foreach (var stream in state.MediaSource.MediaStreams) @@ -2738,21 +2747,19 @@ namespace MediaBrowser.Api.Playback } } } + } - //var videoStream = state.VideoStream; - //if (videoStream != null && !string.IsNullOrWhiteSpace(videoStream.Codec)) - //{ - // inputModifier += " -codec:0 " + videoStream.Codec; + return inputModifier; + } - // var audioStream = state.AudioStream; - // if (audioStream != null && !string.IsNullOrWhiteSpace(audioStream.Codec)) - // { - // inputModifier += " -codec:1 " + audioStream.Codec; - // } - //} + private string GetInputFormat(string container) + { + if (string.Equals(container, "mkv", StringComparison.OrdinalIgnoreCase)) + { + return "matroska"; } - return inputModifier; + return container; } private string GetDecoderFromCodec(string codec) diff --git a/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs b/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs index 97072115dc..41b58a611f 100644 --- a/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs +++ b/MediaBrowser.Api/Playback/Hls/BaseHlsService.cs @@ -103,7 +103,7 @@ namespace MediaBrowser.Api.Playback.Hls throw; } - var waitForSegments = state.SegmentLength >= 10 ? 2 : 3; + var waitForSegments = state.SegmentLength >= 10 ? 2 : 2; await WaitForMinimumSegmentCount(playlist, waitForSegments, cancellationTokenSource.Token).ConfigureAwait(false); } } |
