浏览代码

update live stream generation

Luke Pulverenti 10 年之前
父节点
当前提交
dd8dd1938a

+ 1 - 1
MediaBrowser.Api/ApiEntryPoint.cs

@@ -187,7 +187,7 @@ namespace MediaBrowser.Api
 
             if (!string.IsNullOrWhiteSpace(deviceId))
             {
-                var audioCodec = state.ActualOutputVideoCodec;
+                var audioCodec = state.ActualOutputAudioCodec;
                 var videoCodec = state.ActualOutputVideoCodec;
 
                 _sessionManager.ReportTranscodingInfo(deviceId, new TranscodingInfo

+ 4 - 0
MediaBrowser.Api/Playback/BaseStreamingService.cs

@@ -1513,6 +1513,10 @@ namespace MediaBrowser.Api.Playback
                 {
                     request.StreamId = val;
                 }
+                else if (i == 22)
+                {
+                    request.LiveStreamId = val;
+                }
             }
         }
 

+ 9 - 0
MediaBrowser.Controller/LiveTv/LiveTvChannel.cs

@@ -82,6 +82,15 @@ namespace MediaBrowser.Controller.LiveTv
         /// <value><c>null</c> if [has image] contains no value, <c>true</c> if [has image]; otherwise, <c>false</c>.</value>
         public bool? HasProviderImage { get; set; }
 
+        public override LocationType LocationType
+        {
+            get
+            {
+                // TODO: This should be removed
+                return LocationType.Remote;
+            }
+        }
+
         protected override string CreateSortName()
         {
             double number = 0;

+ 7 - 0
MediaBrowser.Model/ApiClient/IApiClient.cs

@@ -1486,5 +1486,12 @@ namespace MediaBrowser.Model.ApiClient
         /// <param name="query">The query.</param>
         /// <returns>Task&lt;List&lt;RecommendationDto&gt;&gt;.</returns>
         Task<List<RecommendationDto>> GetMovieRecommendations(MovieRecommendationQuery query);
+        /// <summary>
+        /// Opens the live stream.
+        /// </summary>
+        /// <param name="request">The request.</param>
+        /// <param name="cancellationToken">The cancellation token.</param>
+        /// <returns>Task&lt;LiveStreamResponse&gt;.</returns>
+        Task<LiveStreamResponse> OpenLiveStream(LiveStreamRequest request, CancellationToken cancellationToken);
     }
 }

+ 3 - 0
MediaBrowser.Model/Dlna/StreamInfo.cs

@@ -210,6 +210,9 @@ namespace MediaBrowser.Model.Dlna
             list.Add(new NameValuePair("StreamId", streamId ?? string.Empty));
             list.Add(new NameValuePair("api_key", accessToken ?? string.Empty));
 
+            string liveStreamId = item.MediaSource == null ? null : item.MediaSource.LiveStreamId;
+            list.Add(new NameValuePair("LiveStreamId", liveStreamId ?? string.Empty));
+
             return list;
         }
 

+ 19 - 0
MediaBrowser.Model/MediaInfo/LiveStreamRequest.cs

@@ -12,5 +12,24 @@ namespace MediaBrowser.Model.MediaInfo
         public int? SubtitleStreamIndex { get; set; }
         public string ItemId { get; set; }
         public DeviceProfile DeviceProfile { get; set; }
+
+        public LiveStreamRequest()
+        {
+            
+        }
+
+        public LiveStreamRequest(AudioOptions options)
+        {
+            MaxStreamingBitrate = options.MaxBitrate;
+            ItemId = options.ItemId;
+            DeviceProfile = options.Profile;
+
+            VideoOptions videoOptions = options as VideoOptions;
+            if (videoOptions != null)
+            {
+                AudioStreamIndex = videoOptions.AudioStreamIndex;
+                SubtitleStreamIndex = videoOptions.SubtitleStreamIndex;
+            }
+        }
     }
 }

+ 5 - 0
MediaBrowser.Model/Session/PlaybackProgressInfo.cs

@@ -78,5 +78,10 @@ namespace MediaBrowser.Model.Session
         /// </summary>
         /// <value>The play method.</value>
         public PlayMethod PlayMethod { get; set; }
+        /// <summary>
+        /// Gets or sets the live stream identifier.
+        /// </summary>
+        /// <value>The live stream identifier.</value>
+        public string LiveStreamId { get; set; }
     }
 }

+ 5 - 0
MediaBrowser.Model/Session/PlaybackStopInfo.cs

@@ -36,5 +36,10 @@ namespace MediaBrowser.Model.Session
         /// </summary>
         /// <value>The position ticks.</value>
         public long? PositionTicks { get; set; }
+        /// <summary>
+        /// Gets or sets the live stream identifier.
+        /// </summary>
+        /// <value>The live stream identifier.</value>
+        public string LiveStreamId { get; set; }
     }
 }

+ 10 - 2
MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs

@@ -356,7 +356,11 @@ namespace MediaBrowser.Server.Implementations.LiveTv
                     _logger.Info("Opening channel stream from {0}, external channel Id: {1}", service.Name, channel.ExternalId);
                     info = await service.GetChannelStream(channel.ExternalId, null, cancellationToken).ConfigureAwait(false);
                     info.RequiresClosing = true;
-                    info.LiveStreamId = info.Id;
+
+                    if (info.RequiresClosing)
+                    {
+                        info.LiveStreamId = info.Id;
+                    }
                 }
                 else
                 {
@@ -367,7 +371,11 @@ namespace MediaBrowser.Server.Implementations.LiveTv
                     _logger.Info("Opening recording stream from {0}, external recording Id: {1}", service.Name, recording.RecordingInfo.Id);
                     info = await service.GetRecordingStream(recording.RecordingInfo.Id, null, cancellationToken).ConfigureAwait(false);
                     info.RequiresClosing = true;
-                    info.LiveStreamId = info.Id;
+
+                    if (info.RequiresClosing)
+                    {
+                        info.LiveStreamId = info.Id;
+                    }
                 }
 
                 _logger.Info("Live stream info: {0}", _jsonSerializer.SerializeToString(info));

+ 24 - 0
MediaBrowser.Server.Implementations/Session/SessionManager.cs

@@ -679,6 +679,18 @@ namespace MediaBrowser.Server.Implementations.Session
                 }
             }
 
+            if (!string.IsNullOrWhiteSpace(info.LiveStreamId))
+            {
+                try
+                {
+                    await _mediaSourceManager.PingLiveStream(info.LiveStreamId, CancellationToken.None).ConfigureAwait(false);
+                }
+                catch (Exception ex)
+                {
+                    _logger.ErrorException("Error closing live stream", ex);
+                }
+            }
+
             EventHelper.FireEventIfNotNull(PlaybackProgress, this, new PlaybackProgressEventArgs
             {
                 Item = libraryItem,
@@ -769,6 +781,18 @@ namespace MediaBrowser.Server.Implementations.Session
                 }
             }
 
+            if (!string.IsNullOrWhiteSpace(info.LiveStreamId))
+            {
+                try
+                {
+                    await _mediaSourceManager.CloseLiveStream(info.LiveStreamId, CancellationToken.None).ConfigureAwait(false);
+                }
+                catch (Exception ex)
+                {
+                    _logger.ErrorException("Error closing live stream", ex);
+                }
+            }
+
             EventHelper.QueueEventIfNotNull(PlaybackStopped, this, new PlaybackStopEventArgs
             {
                 Item = libraryItem,

+ 2 - 2
Nuget/MediaBrowser.Common.Internal.nuspec

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

+ 1 - 1
Nuget/MediaBrowser.Common.nuspec

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

+ 1 - 1
Nuget/MediaBrowser.Model.Signed.nuspec

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

+ 2 - 2
Nuget/MediaBrowser.Server.Core.nuspec

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